Adds the field.

@param FieldInterface $field

@return $this|Definition
172434
public function addField(FieldInterface $field): Definition
    {
        $name = $field->getName();

        if ($this->hasField($name)) {
            throw new DefinitionException("Field '$name' is already defined.");
        }

        $this->fields[$name] = $field;

        return $this;
    }
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;
    }
47129
public function in($field, $value) {
        $this->add($field, Expr::IN, (array) $value);

        return $this;
    }
822136
public function addFieldFromConfig($name, $field)
    {
        $this->addField(Fields::create($name, $field));
        return $this;
    }
504515
public function addAttribute(AttributeInterface $attribute)
    {
        if (!$this
            ->attributes
            ->contains($attribute)) {
            $this
                ->attributes
                ->add($attribute);
        }

        return $this;
    }
524574
public function prependField(FieldDefinition $field): FieldsAwareDefinitionInterface
    {
        $this->fields = array_merge([$field->getName() => $field], $this->fields);

        return $this;
    }
914597
public function addOption(OptionInterface $option)
    {
        if (!$this->hasOption($option)) {
            $this->options->add($option);
        }

        return $this;
    }
582011
public function addField(FormField $field)
    {
        if ($this->fields->contains($field) === false) {
            $field->setForm($this);
            $this->fields->add($field);
        }

        return $this;
    }
301814
public function visitField(FieldInterface $field)
    {
        $template = 'field/' . $field->getType() . '.twig';

        return $this
            ->loadTemplate($template)
            ->render(
                [
                    "id" => $field->getId(),
                    "classes" => $field->getClasses(),
                    "data" => $field->getData(),
                    "slug" => $field->getSlug(),
                    "initial" => $field->getInitial(),
                    "choices" => $field->getChoices(),
                    "label" => $field->getLabel(),
                    "required" => $field->isRequired(),
                    "size" => $field->getSize(),
                    "errors" => $field->getErrors(),
                    "helptext" => $field->getHelptext(),
                    "placeholder" => $field->getPlaceholder()
                ]
            );
    }
79673
public function add(DefinitionInterface $definition)
    {
        $index = count($this->_names);
        $this->_definitionSource[$index] = $definition;
        $this->_names[$definition->getName()] = $index;
        return $this;
    }
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;
	}
382607
public function & SetField (\MvcCore\Ext\Forms\IField & $field) {
		$this->__protected['fieldRendering'] = TRUE;
		$this->field = & $field;
		return $this;
	}
318581
public function pushField(Field $field)
    {
        $field = $this->formatField($field);

        $this->fields->push($field);

        return $this;
    }
305627
public function addFieldValue(FieldValueInterface $fieldValue)
    {
        $this->fieldValues[] = $fieldValue;
        $fieldValue->setContent($this);

        return $this;
    }
966891
public function addField(FieldTypeInterface $field, SectionInterface $group): FieldsRepositoryInterface
    {
        // We store all fields together
        // as well as per group. On each form,
        // there is a "default" group defined where
        // all fields are attached to. A user can specify
        // a form group to the passed options on the "add"
        // method of the FormBuilder instance.
        $this->fields[$field->getBaseName()] = $field;
        $this->groups[$group->getId()] = $group;

        return $this;
    }
1368315
private function updateFieldDefinition(FieldDefinitionObject $field)
    {
        $definition = $this->contentTypeService->newFieldDefinitionUpdateStruct();
        $field->getMapper()->mapObjectToUpdateStruct($definition);

        return $definition;
    }
529466
public function addFields($fields)
    {
        if ($fields instanceof FieldsBuilder) {
            $builder = clone $fields;
            $fields = $builder->getFields();
        }

        foreach ($fields as $field) {
            $this->getFieldManager()->pushField($field);
        }

        return $this;
    }