Add a field that should be stored

@param string $field The field to add
@param string $forceType The type to force this field as (required in some cases, when not
detectable from metadata)
@param array $extraOptions Dependent on search implementation
481133
public function addStoredField($field, $forceType = null, $extraOptions = array())
    {
        $options = array_merge($extraOptions, array('stored' => 'true'));
        $this->addFulltextField($field, $forceType, $options);
    }
999617
public function add(FieldTypeInterface $field): FormBuilderInterface
    {
        /** @var BaseType $field */
        $opts = $this->validateOptions(array_merge([
            'errors' => $this->form->getOption('errors'),
            'theme' => $this->form->getOption('theme')
        ], $field->getOptions()), $field);
        $field->setLocale($this->form->getLocale());
        $field->setOptions($opts);
        $field->setForm($this->form);
        $field->setViewFactory($this->form->getViewer());
        $field->setResourceTransformerFactory($this->form->getResourceTransformerFactory());

        // DTO
        if (! is_null($this->dataClass) && is_object($this->dataClass) && $field->getOption('mapped')) {
            $this->dataMapperManager->mapFromObjectToField($this->dataClass, $field);
        }

        // Check if section instance already exists on the form.
        // If not, create a new section instance.
        if ($this->form->repository()->hasGroup($field->getOption('group'))) {
            // The section/group instance is already registered, just fetch it.
            $section = $this->form->repository()->getGroup($field->getOption('group'));
        } else {
            // No defined group. Let's create an instance so we can attach
            // the field to it right after.
            $section = new Section($field->getOption('group'));
        }

        // Setup group/section default view.
        $section->setTheme($this->form->getTheme());
        $section->setView('form.group');

        // Add the field first to section instance.
        // Then pass both objects to the repository.
        $section->addItem($field);
        $this->form->repository()->addField($field, $section);

        return $this;
    }
906633
public function addOption(OptionInterface $option): void
    {
        $option->setSelected($option->getValue() === $this->value);

        if ($option->getValue() === '') {
            $this->hasEmptyOption = true;
        }

        $this->options[] = $option;
    }
1154636
public function buildQuery($type, $field = null, $extra = null)
    {
        if($type == 'select') {
            if($field == null) {
                $field = "*";
            }
            elseif(is_array($field)) {
                foreach($field as $i => $value) {
                    $field[$i] = '`'.trim($value).'`';
                }
                $field = trim(implode(' ,', $field));
            }
            $ex = '';
            if($extra != null && is_array($extra)) {
                foreach($extra as $i => $v) {
                    if($i == 'count') {
                        $ex .= 'COUNT';
                        if($v == null) {
                            $ex .= '(*)';
                        }
                    }
                    if($i == 'field') {
                        $ex .= ' as `'.$v.'`';
                    }
                }
                $sql = "SELECT $ex FROM `".$this->getTable().'` '.$this->where;
            }
            else {
                $sql = "SELECT $field FROM `".$this->getTable().'` '.$this->where.$this->order.$this->limit;
            }
        }
        elseif($type == 'insert') {
            if(is_array($field)) {
                $keys = array_keys($field);
                if($keys[0] === 0) {
                    $keys = '';
                }
                else {
                    foreach($keys as $i => $key) {
                        $keys[$i] = ' `'.trim($key).'`';
                    }
                    $keys = implode(',', $keys);
                }
                $values = array_values($field);
                foreach($values as $i => $val) {
                    $values[$i] = is_string($val) ? "'$val'" : $val;
                }
                $values = implode(' ,', $values);
            }
            else {
                $keys = '';
                $values = trim($field);
            }
            $values = "($values)";
            $keys = ($keys !== '') ? "($keys)" : '';
            $sql = "INSERT INTO `".$this->getTable()."` $keys VALUES $values".$this->duplicateUpdate;
        }
        elseif($type == 'update') {
            if(is_array($field)) {
                foreach($field as $key => $value) {
                    $values[] = " `$key` = ".(is_string($value) ? "'$value'" : $value);
                }
                $values = implode(' ,', $values);
            }
            else {
                $values = trim($field);
            }
            $sql = "UPDATE `".$this->getTable()."` SET $values ".$this->where;
        }
        elseif($type == 'delete') {
            $sql = "DELETE FROM `".$this->getTable()."` ".$this->where;
        }
        $this->query = $sql;
        return $sql;
    }
355441
public function & AddField (\MvcCore\Ext\Forms\IField $field) {
		/** @var $this \MvcCore\Ext\Forms\IForm */
		/** @var $field \MvcCore\Ext\Forms\Field */
		if ($this->dispatchState < 1) $this->Init();
		$fieldName = $field->GetName();
		$field->SetForm($this);
		$this->fields[$fieldName] = & $field;
		if ($field instanceof \MvcCore\Ext\Forms\Fields\ISubmit) {
			$this->submitFields[$fieldName] = & $field;
			$fieldCustomResultState = $field->GetCustomResultState();
			if ($fieldCustomResultState !== NULL)
				$this->customResultStates[$fieldName] = $fieldCustomResultState;
		}
		return $this;
	}
371722
private function prepareOptions($options, $forceOptions = [])
    {
        $optionString = '';

        foreach ($forceOptions as $option => $value) {
            if (is_numeric($option)) {
                $options[$value] = null;
            } else {
                $options[$option] = $value;
            }
        }

        foreach ($options as $option => $value) {

            if (is_null($value)) {
                $optionString .= ' ' . $option;
            } else {
                $optionString .= ' ' . $option . '=' . $value;
            }
        }

        return $optionString;
    }
1097424
protected function setType(string $type) : void
    {
        if (empty($type)) {
            throw new InvalidArgumentException(__CLASS__ . ': Empty field type is not allowed');
        }

        if (! in_array($type, array_keys($this->defaultOptions))) {
            throw new InvalidArgumentException(__CLASS__ . ': Unsupported field type: ' . $type);
        }

        $this->type = $type;
    }
694283
private function injectExtraConfig(PackageInterface $package, array $extra)
    {
        $ref = new \ReflectionClass($package);
        $met = $ref->getProperty('extra');
        $met->setAccessible(true);
        $met->setValue($package, $extra);
    }
1201110
public function addField(Field $field)
    {
        $field
            ->setSection($this->currentSection)
            ->setOptionName($this->registry['option_name'])
        ;

        if (isset($this->registry['field_values'][$field->getId()])) {
            $field->setValue($this->registry['field_values'][$field->getId()]);
        }

        $this->registry['fields'][] = $field;

        return $this;
    }
317375
private function AddTypeField()
    {
        $name = 'Type';
        $select = new Select($name, $this->textfield->GetType());
        $select->AddOption('', Trans('Core.PleaseSelect'));
        $values = TextfieldType::AllowedValues();
        foreach ($values as $value)
        {
            $select->AddOption($value, Trans('Forms.TextfieldType.' . ucfirst($value)));
        }
        $this->AddField($select);
        $this->SetRequired($name);
    }
796417
public static function create($type, $value, $extra = null)
    {
        switch (strtolower($type)) {
            case 'int':
            case 'integer':
                return self::createInt($value);
            case 'float':
            case 'double':
                return self::createFloat($value);
            case 'string':
                return self::createString($value);
            case 'bool':
            case 'boolean':
                return self::createBool($value);
            case 'digit':
                return self::createDigit($value);
            case 'natural':
                return self::createNatural($value);
            case 'whole':
                return self::createWhole($value);
            case 'complex':
                return self::createComplex($value, $extra);
            case 'rational':
                return self::createRational($value, $extra);
            default:
                throw new InvalidTypeException(strtolower($type));
        }
    }
184451
protected function attemptBasic(Request $request, $field, $extraConditions = [])
    {
        if (! $request->getUser()) {
            return false;
        }

        return $this->attempt(array_merge(
            $this->basicCredentials($request, $field), $extraConditions
        ));
    }
104097
public function append (Field $field)
    {
        if (in_array($field, $this->_fields, true)) {
            throw new InvalidArgumentException("{$this} already contains {$field}");
        }
        $this->_fields []= $field;
    }
973661
public function setupElfinder(array $extraOptions = [])
    {
        if (!defined('ELFINDER_IMG_PARENT_URL')) {
            // Ensure images injected by elFinder are relative to its assets directory
            define('ELFINDER_IMG_PARENT_URL', $this->baseUrl(ElfinderTemplate::ELFINDER_ASSETS_REL_PATH));
        }

        $options = $this->buildConnectorOptions($extraOptions);

        // Run elFinder
        $connector = new elFinderConnector(new elFinder($options));
        $connector->run();

        return $connector;
    }
1110199
protected function saveOptions(CustomField $field, Field $customfield)
    {
        if (is_null($field->options)) {
            return false;
        }
        $options = ($field->options instanceof Closure) ? call_user_func($field->options) : $field->options;
        foreach ($options as $value => $label) {
            FieldTypeOption::query()->firstOrCreate([
                'field_id' => $customfield->id,
                'label'    => $label,
                'value'    => $value
            ]);
        }
        return true;
    }
876049
public function extra(array $extra = [], $override = true)
    {
        TypeChecker::isArray($extra);
        if (! $override) {
            $extra = array_merge($this->getNotificationData('extra', []), $extra);
        }
        $this->setNotificationData('extra', $extra);

        return $this;
    }
1070417
public function add(AbstractType $field, $offset = null)
    {
        $field->setForm($this);

        if ($offset === null) {
            $this->fields[$field->getName()] = $field;
        } else {
            if ($offset < 0) {
                $totalFields = \count($this->fields);
                $offset      = $totalFields - $offset + 1;
            }

            // Add the field at the specified offset
            $this->fields = \array_merge(
                \array_slice($this->fields, 0, $offset, true),
                [$field->getName() => $field],
                \array_slice($this->fields, $offset, null, true)
            );
        }

        return $this;
    }