File template.

@param  \Antares\Contracts\Html\Form\Field $field

@return string
559670
public function file(FieldContract $field)
    {
        $attributes = $this->html->decorate($field->get('attributes'), ['class' => 'form-control']);
        return $this->form->file($field->get('name'), $attributes);
    }
25451
public function format_button($field)
    {
        $class = $this->columns[$field]['button_class'];

        $icon = $this->columns[$field]['icon'];
        if ($icon) {
            if ($icon[0] != '<') {
                $icon = '<span class="icon-'.$icon.'"></span>';
            }
            $icon .= '&nbsp;';
        }

        $this->current_row_html[$field] =
            '<button class="atk-button-small do-'.$field.'  '.$class.'" data-id="'.$this->model->id.'">'.
                $icon.$this->columns[$field]['descr'].
            '</button>';
    }
728136
public function file($field, $label) {
        $file = new File($this->_entity, $field, $label);
        array_push($this->_elements, $file);

        return $file;
    }
817935
public function render_field($field)
    {
        /*
        *  Review the data of $field.
        *  This will show what data is available
        */

        /**
         * TODO
         *
         * => Render out icons within the select options
         */


        //echo '<pre>';
        //print_r($field);
        //echo '</pre>';

        if (!is_array($this->dropdownOptions($field)) || empty($this->dropdownOptions($field))) {
            return;
        }

        $output = '';

        $output .= '<select class="c-pricons-dropdown" name="' . $field['name'] . '">';

        if ($field['value'] == "") {
            $output .= '<option class="c-pricons-dropdown__option" value="" selected>Select an icon</option>';
        } else {
            $output .= '<option class="c-pricons-dropdown__option" value="">Select an icon</option>';
        }


        foreach ($this->dropdownOptions($field) as $value => $label) {
            if ($value == $field['value']) {
                $output .= '<option class="c-pricons-dropdown__option" value="' . $value . '" selected>' . $label . '</option>';
            } else {
                $output .= '<option class="c-pricons-dropdown__option" value="' . $value . '">' . $label . '</option>';
            }
        }

        $output .= '</select>';

        echo $output;
    }
1131060
public function js_data( $field ) {
		$value = $field->get_value();

		// Preapre attachment for the preview.
		$attachment = [];

		// Fake an attachment model - needs all fields used by template.
		// Note that the default value must be a URL, NOT an attachment ID.
		if ( ! $value && $_default = $field->get_default() ) {
			$type = in_array( substr( $_default, -3 ), [ 'jpg', 'png', 'gif', 'bmp' ] ) ? 'image' : 'document';

			$attachment = [
				'id'    => 1,
				'url'   => $_default,
				'type'  => $type,
				'icon'  => wp_mime_type_icon( $type ),
				'title' => basename( $_default ),
			];

			if ( 'image' === $type ) {
				$attachment['sizes'] = [ 'full' => [ 'url' => $_default ] ];
			}
		} elseif ( $value ) {
			$attachment = wp_prepare_attachment_for_js( $value );
		}

		return [
			'mime_type'  => $this->mime_type,
			'attachment' => $attachment,
			'labels'     => Arr::only( $this->get_button_labels(), [ 'frame_title', 'frame_button' ] ),
		];
	}
819093
protected function getFieldItem(Field $field)
    {
        if ($field->hasForeignRelation()) {
            $relation = $field->getForeignRelation();

            return sprintf('$%s', $relation->getSingleName());
        }

        return '$text';
    }
969112
public function hasFieldValue($field)
    {
        $newFiles = array_get($this->files, 'new.image', []);

        foreach ($newFiles as $fieldName => $file) {
            if ($fieldName == $field) {
                return true;
            }
        }

        $existingFiles = array_get($this->files, 'image', []);

        foreach ($existingFiles as $fieldName => $files) {
            if ($fieldName == $field) {
                $deleted = 0;
                $fileCount = count($files);
                foreach ($files as $file) {
                    if ($file['delete']) {
                        ++$deleted;
                    }
                }
                if ($fileCount == $deleted) {
                    return false;
                } else {
                    return true;
                }
            }
        }

        return false;
    }
444643
public static function generateLabel($field)
    {
        $label = Str::title(str_replace('_', ' ', $field['fieldName']));
        $template = "{!! Form::label('\$FIELD_NAME\$', '\$FIELD_NAME_TITLE\$:', ['class' => 'form-control-label $FIELD_NAME_TITLE$']) !!}";
        $template = str_replace('$FIELD_NAME_TITLE$', $label, $template);
        $template = str_replace('$FIELD_NAME$', $field['fieldName'], $template);
        return $template;
    }
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>';
    }
711816
public function build($field)
    {
        $return = '';
        if (\is_array($field)) {
            $field = $this->fieldFactory->build($field);
        }
        $this->field = $field;
        $this->props = $field->props;
        $id = $field->getId();
        $isBuilding = \in_array($id, $this->building);
        $uniqueId = $field->getUniqueId(!$isBuilding);
        $this->setIds($uniqueId);
        if (!$isBuilding) {
            $this->building[] = $id;
        }
        $this->addAttributes();
        if (!$isBuilding) {
            $return = $field->doBuild();
        }
        if (!$return) {
            $return = $this->doBuild();
        }
        $return = $this->removeEmptyTags($return);
        $key = \array_search($id, $this->building);
        if ($key !== false) {
            unset($this->building[$key]);
        }
        return $return;
    }
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;
    }
870222
public function imageUrl($field = null)
    {
        $this->uploadFieldName = $this->getUploadFieldName($field);
        $this->uploadFieldOptions = $this->getUploadFieldOptions($this->uploadFieldName);

        // get the model attribute value
        $attributeValue = $this->getOriginal($this->uploadFieldName);

        // check for placeholder defined in option
        $placeholderImage = array_get($this->uploadFieldOptions, 'placeholder');

        return (empty($attributeValue) && $placeholderImage)
            ? $placeholderImage
            : $this->getStorageDisk()->url($attributeValue);
    }
1002484
public function createSet(string $field, $value): string
    {
        $field = $this->markField($field);
        return $field . ' = ' . $value;
    }
1071109
protected function renderElement($field)
    {
        $type = $field['type'];
        switch ($type) {
            case 'textarea':
            case 'markup':
            case 'select':
            case 'radio':
            case 'checkbox':
                return $this->$type($field);
            default:
                return $this->input($field);
        }
    }
712019
public function format_shorttext($field)
    {
        $text = $this->current_row[$field];
        if (strlen($text) > 60) {
            // Not sure about multi-byte support and execution speed of this
            $a = explode(PHP_EOL, wordwrap($text, 28, PHP_EOL, true), 2);
            $b = explode(PHP_EOL, wordwrap(strrev($text), 28, PHP_EOL, true), 2);
            $text = $a[0].' ~~~ '.strrev($b[0]);
        }

        $this->current_row[$field] = $text;

        $this->setTDParam(
            $field,
            'title',
            $this->app->encodeHtmlChars(strip_tags($this->current_row[$field.'_original']), ENT_QUOTES)
        );
    }
386604
protected function serializeQuizField(string $field): string
    {
        return str_replace(['\\', ',', '=', "\n"], ['\\\\', '，', '＝', '\\n'], $this->convertToShiftJISable($field));
    }
975119
private function render(Field $field)
    {
        $field->set('lang', $this->language);
        $field->set('prefix', $this->buildPrefix($field));

        foreach ($this->fill($field->getAttributes()) as $key => $value) {
            $field->set($key, $value);
        }

        return $field->render();
    }