Formats a field definition.

@param  array $field A partial field definition.
@return array        A complete field definition.
6931
public function field($field)
    {
        if (!isset($field['name'])) {
            throw new SqlException("Missing column name.");
        }
        if (!isset($field['use'])) {
            if (isset($field['type'])) {
                $field += $this->type($field['type']);
            } else {
                $field += $this->type('string');
            }
        }
        return $field + [
            'name'      => null,
            'type'      => null,
            'length'    => null,
            'precision' => null,
            'serial'    => false,
            'default'   => null,
            'null'      => null
        ];
    }
259872
private static function getFieldTypeArray($fields)
    {
        if (count($fields) === 0) {
            return;
        }

        $types = array();

        foreach ($fields as &$field) {
            $types[] = $field->type;
        }

        return $types;
    }
1207105
protected static function cleanFields($fields)
    {
        $new = [];
        $fieldList = explode(',', $fields);
        foreach ($fieldList as $f) {
            if (static::ID_FIELD !== trim(strtolower($f))) {
                $new[] = $f;
            }
        }

        return implode(',', $new);
    }
68046
protected function fieldsetBegin(array $field)
    {
        $output = '';
        $output .= $this->getWrapper($field['type'], $field['attributes']);
        $titleTag = $field['type'] === 'fieldset' ? 'legend' : 'summary';
        if (!empty($field[$titleTag])) {
            $output .= $this->getWrapper($titleTag, $field['attributes']);
            $output .= $field[$titleTag];
            $output .= $this->getWrapperEnd($titleTag);
        }
        $output .= $this->getWrapper('fieldsetContent');
        if (!empty($field['description'])) {
            $output .= $this->renderDescription($field['description'], true);
        }
        return $output;
    }
408518
public function fields($fields) {

        if ( is_array($fields) ) {
            $this->fields = '`'.implode("`, `", $fields).'`';
        } else if ( is_string($fields) ) {
            $this->fields = $fields;
        } else {
            $this->fields = '*';
        }
        return $this;
    }
968148
public function order($field) {
        $order = [];
        if (is_array($field)) {
            foreach ($field as $key => $value) {
                $order[] = $key . ' ' . $value;
            }
        } else {
            $order = func_get_args();
        }
        $order = implode(',', $order);
        $this->order = !empty($order) ? ' ORDER BY ' . $order : '';
        return $this;
    }
2946
public static function cleanField($field) {
        if ('*' == $field) {
            return $field;
        }
        $strings = explode('.', $field);
        $fields  = [];
        foreach ($strings as $str) {
            $strs = preg_split('#\bas\b#i', $str);
            $fs   = [];
            foreach ($strs as $s) {
                if ($s == '*') {
                    $fs [] = '*';
                } else {
                    $fs [] = '`' . trim(trim(trim($s), '`')) . '`';
                }
            }
            $fields [] = implode(' AS ', $fs);
        }

        return implode('.', $fields);
    }
1347130
public static function transform_sub_post_fields( &$field ) {
		if ( is_array( $field['value'] ) ) {
			$data = [];
			foreach ( $field['value'] as $post_id ) {
				$data[] = Acf::get_post_field( $post_id );
			}
			$field['value'] = $data;
		} else {
			$field['value'] = Acf::get_post_field( $field['value'] );
		}
	}
360530
public function stringify(array $fields): string
    {
        $normalized = $this->normalizerFormatter->format($fields);
        $prettyPrintFlag = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 128;

        $hasSecondDimension = count(array_filter($normalized, 'is_array'));
        $hasNonNumericKeys = !count(array_filter(array_keys($normalized), 'is_numeric'));

        return $hasSecondDimension || $hasNonNumericKeys
            ? json_encode($normalized, $prettyPrintFlag|JSON_UNESCAPED_UNICODE)
            : json_encode($normalized, JSON_UNESCAPED_UNICODE);
    }
851053
private static function patternDeclared(array $fields)
    {
        foreach ($fields as $i => $field) {
            $fields[$i] = ucfirst($field);
        }

        return sprintf('`^([a-z]+)(%s)$`', implode('|', $fields));
    }
628636
public function getFieldType($field)
    {
        $definition = $this->getFieldDefinition($field);
        if ($definition && isset($definition['type'])) {
            return $definition['type'];
        }
    }
189617
protected static function filter($field)
    {
        $field = preg_replace('/[\.\/\\:;,?$*!#_-]/', '', $field);
        $field = preg_replace('/\s+/', ' ', trim($field));
        return $field;
    }
1280540
public function render_field($field)
    {
        // convert value to array
        $field['value'] = acf_get_array($field['value'], false);

        // add empty value (allows '' to be selected)
        if (empty($field['value'])) {
            $field['value'][''] = '';
        }

        // placeholder
        if (empty($field['placeholder'])) {
            $field['placeholder'] = __("Select",'acf');
        }

        // vars
        $atts = array(
            'id'                => $field['id'],
            'class'             => $field['class'],
            'name'              => $field['name'],
            'data-multiple'     => $field['multiple'],
            'data-placeholder'  => $field['placeholder'],
            'data-allow_null'   => $field['allow_null']
        );

        // multiple
        if ($field['multiple']) {
            $atts['multiple'] = 'multiple';
            $atts['size'] = 5;
            $atts['name'] .= '[]';
        }

        // special atts
        foreach (array( 'readonly', 'disabled' ) as $k) {
            if (!empty($field[ $k ])) {
                $atts[ $k ] = $k;
            }
        }

        // vars
        $els = array();
        // $choices = array();

        $posttypes = $this->post_type_options();
        foreach ($posttypes as $pt) {
            $els[] = array(
                'type' => 'option',
                'value' => $pt['value'],
                'label' => $pt['label'],
                'selected' => in_array($pt['value'], $field['value'])
            );
        }

        // null
        if ($field['allow_null']) {
            array_unshift($els, array(
                'type' => 'option',
                'value' => '',
                'label' => '- ' . $field['placeholder'] . ' -'
            ));
        }

        // html
        echo '<select ' . acf_esc_attr($atts) . '>';

        // construct html
        if (!empty($els)) {
            foreach ($els as $el) {
                // extract type
                $type = acf_extract_var($el, 'type');
                if ($type == 'option') {
                    // get label
                    $label = acf_extract_var($el, 'label');
                    // validate selected
                    if (acf_extract_var($el, 'selected')) {
                        $el['selected'] = 'selected';
                    }

                    // echo
                    echo '<option ' . acf_esc_attr($el) . '>' . $label . '</option>';
                } else {
                    // echo
                    echo '<' . $type . ' ' . acf_esc_attr($el) . '>';
                }


            }

        }

        echo '</select>';
    }
1111079
public function getValFormatted($field)
    {
        $val = $field->valRaw();
        $val = \preg_replace('/[^\d.-]/', '', $val);
        $val = \strlen($val)
            ? \sprintf('%.2f', $val)
            : null;
        return $val === null
            ? null
            : '$'.\number_format($val, 2);
    }
655674
public function getValFormatted($field)
    {
        $val = $field->valRaw();
        if (\preg_match('|^(\d{3})[\. -]?(\d{2})[\. -]?(\d{4})$|', $val, $matches)) {
            list($area, $group, $serial) = \array_slice($matches, 1);
            return $area.'-'.$group.'-'.$serial;
        }
        return null;
    }
171824
public function makeFieldReadonly($field)
    {
        if (!is_array($field)) {
            $field = [$field];
        }

        foreach ($field as $item) {
            $fieldName = ($item instanceof FormField) ? $item->getName() : $item;
            $srcField = $this->dataFieldByName($fieldName);
            if ($srcField) {
                $this->replaceField($fieldName, $srcField->performReadonlyTransformation());
            } else {
                user_error("Trying to make field '$fieldName' readonly, but it does not exist in the list", E_USER_WARNING);
            }
        }
    }
26835
protected function input(array $field)
    {
        $output = '';

        // Tag around input element.
        $output .= $this->getWrapper('input');

        $attributes = $field['attributes'];
        $attributes = $this->addAttribute($attributes, 'type', $field['type']);
        $attributes = $this->addAttribute($attributes, 'id', $field['id']);
        $attributes = $this->addAttribute($attributes, 'name', $field['name']);
        $attributes = $this->addAttribute($attributes, 'value', $field['value']);
        $output .= $this->getOpenTag('input', $attributes, true);

        // Tag around input element.
        $output .= $this->getWrapperEnd('input');

        return $output;
    }