Returns a mapped simple element.

@param array $field

@return array
160062
protected function element(array $field)
    {
        $result = array(
            'type' => $this->getPrestaShopType($field['type']),
            'label' => isset($field['label']) ? $field['label'] : '',
            'name' => $field['name'],
            'required' => isset($field['attributes']['required']) ? $field['attributes']['required'] : false,
            'multiple' => isset($field['attributes']['multiple']) ? $field['attributes']['multiple'] : false,
        );

        if (!empty($field['attributes'])) {
            $result['attributes'] = $field['attributes'];
        }
        if (isset($field['description'])) {
            $result['desc'] = $field['description'];
        }

        if ($field['type'] === 'radio') {
            $result['values'] = $this->getPrestaShopValues($field['name'], $field['options']);
        } elseif ($field['type'] === 'checkbox') {
            $result['values'] = $this->getPrestaShopOptions($field['options']);
        } elseif ($field['type'] === 'select') {
            $result['options'] = $this->getPrestaShopOptions($field['options']);
            if ($result['multiple']) {
                $result['size'] = $field['attributes']['size'];
            }
        }

        return $result;
    }
1335807
private function getFieldValue($field)
    {
        return isset($this->values[$field]) ? $this->values[$field] : null;
    }
377756
public function map(Field $field)
    {
        if (!isset($field->value['latitude'], $field->value['longitude'])) {
            return null;
        }

        return [
            'lat' => $field->value['latitude'],
            'lon' => $field->value['longitude'],
        ];
    }
470262
private function getPlainField($field)
    {
        if (!isset($this->fields[$field['name']])) {                     
			$this->fields[$field['name']] = $this->getDbConnection()->fetchColumn('SELECT `'.$field['name'].'` FROM '.$this->table.' WHERE id='.(int)$this->fields['id']);
		}
        return $this->fields[$field['name']];
    }
97197
public function map($field, $context = null)
    {
        if (array_key_exists('hidden', $field)) {
            $field['hidden'] = (bool) $field['hidden'];
        } else {
            $field['hidden'] = false;
        }

        if (!array_key_exists('restrictions', $field)) {
            $field['restrictions'] = [];
        }

        return $field;
    }
899535
public function get($field)
    {
        if (!is_null($this->filtered) && ! is_null($this->filtered[0])) {
            return isset($this->filtered[0][0][$field]) ? $this->filtered[0][0][$field] : null;
        }

        // Todo: Get values of entities
    }
866516
protected function fields(array $fields)
    {
        $result = array();
        foreach ($fields as $id => $field) {
            if (!isset($field['id'])) {
                $field['id'] = $id;
            }
            if (!isset($field['name'])) {
                $field['name'] = $id;
            }
            $result[$id] = $this->field($field);
        }
        return $result;
    }
1053971
public function values($field)
    {
        $values = [];
        foreach ($this->distinct()->select([$field])->all() as $v) {
            $values[] = $v[$field];
        }

        return $values;
    }
429153
public function getField($field)
    {
        return isset($this->data[$field])
            ? $this->data[$field]
            : $this->searchField($field);
    }
875212
public function getMap(string $field, string $key = 'id', Condition $condition = null): array
    {
        $result = [];
        $select = $this->selectQuery($condition);
        $select->select(['t1.' . $field, 't1.' . $key]);
        if ($rows = $select->execute()->fetchAll(\PDO::FETCH_ASSOC)) {
            foreach ($rows as $row) {
                $this->unserializeFields($row);
                $result[$row[$key]] = $row[$field];
            }
        }

        return $result;
    }
1150442
protected function getAddressFieldValue($field)
    {
        if ($field instanceof \Closure) {
            return call_user_func($field, $this);
        }

        if (is_array($field)) {
            return $this->getRelationalField($field);
        }

        return $this->{$field};
    }
28622
public function get($field = null)
    {
        if ($field === null) {

            // Collect list of eligible fields
            $data = [];
            if ($this->only_fields) {
                // collect data for actual fields
                foreach ($this->only_fields as $field) {
                    $data[$field] = $this->get($field);
                }
            } else {
                // get all field-elements
                foreach ($this->elements as $field => $f) {
                    if ($f instanceof Field) {
                        $data[$field] = $this->get($field);
                    }
                }
            }

            return $data;
        }

        $field = $this->normalizeFieldName($field);

        if (array_key_exists($field, $this->data)) {
            return $this->data[$field];
        }

        $f = $this->hasField($field);

        return $f ? $f->default : null;
    }
1313972
public function resolveForField($field)
    {
        if (! is_null($element = $this->findById($field))) {
            return $element;
        }

        return $this->firstOrFail([
            $field, "input[name='{$field}']", "textarea[name='{$field}']",
            "select[name='{$field}']", "button[name='{$field}']",
        ]);
    }
833965
protected function select(array $field)
    {
        $output = '';

        // Tag around select element: same as for an input element.
        $output .= $this->getWrapper('input');

        // Select tag.
        $attributes = $field['attributes'];
        $attributes = $this->addAttribute($attributes, 'id', $field['id']);
        $attributes = $this->addAttribute($attributes, 'name', $field['name']);
        $output .= $this->getOpenTag('select', $attributes);

        // Options.
        foreach ($field['options'] as $value => $text) {
            $optionAttributes = array('value' => $value);
            if ($this->isOptionSelected($field['value'], $value)) {
                $optionAttributes['selected'] = true;
            }
            $output .= $this->getOpenTag('option', $optionAttributes);
            $output .= htmlspecialchars($text, $this->htmlSpecialCharsFlag, 'UTF-8');
            $output .= $this->getCloseTag('option');
        }

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

        return $output;
    }
170244
private function getValues(array $field)
    {
        if ($field['type'] !== 'select') {
            return null;
        }
        $field = Bag::from($field);

        // Get the appropriate values
        return is_string($field->get('values', [])) ? $this->getEntityValues($field) : $this->getYamlValues($field);
    }
1367576
protected function renderSimpleField(array $field)
    {
        if (!empty($field['ajax'])) {
            $field = $this->addAjax($field);
        }

        $output = '';

        // Split attributes over label and element.
        $attributes = $field['attributes'];
        $labelAttributes = array();
        if (!empty($attributes['label'])) {
            $labelAttributes = $attributes['label'];
            unset($attributes['label']);
        }
        if (!empty($attributes['required'])) {
            $labelAttributes['required'] = $attributes['required'];
        }
        $field['attributes'] = $attributes;

        if ($field['type'] !== 'hidden') {
            $output .= $this->getWrapper('element');
            // Do not use a <label> with an "id" attribute on the label for a
            // set of radio buttons, a set of checkboxes, or on markup.
            $id = in_array($field['type'], array('radio', 'checkbox', 'markup')) ? '' : $field['id'];
            $output .= $this->renderLabel($field['label'], $id, $labelAttributes, true);
            $output .= $this->getWrapper('inputDescription');
        }
        $output .= $this->renderElement($field);
        if ($field['type'] !== 'hidden') {
            $output .= $this->renderDescription($field['description']);
            $output .= $this->getWrapperEnd('inputDescription');
            $output .= $this->getWrapperEnd('element');
        }
        return $output;
    }
339907
public function getFacetedData($field)
    {
        $this->_renderFilters();
        $result = [];
        $aggregations = $this->queryResponse->getAggregations();

        $bucket = $aggregations->getBucket($field);

        if ($bucket) {
            foreach ($bucket->getValues() as $value) {
                $metrics = $value->getMetrics();
                $result[$value->getValue()] = $metrics;
            }
        }

        return $result;
    }