Add a field to the form instance.

@param FieldTypeInterface $field
@param SectionInterface   $group

@return FieldsRepositoryInterface
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;
    }
723595
public function addField(FieldDefinition $field): FieldsAwareDefinitionInterface
    {
        $this->fields[$field->getName()] = $field;

        return $this;
    }
1340574
public function visitSection(SectionInterface $section)
    {

        $template = 'section/' . $section->getType() . '.twig';

        return $this
            ->loadTemplate($template)
            ->render(
                [
                    "id" => $section->getId(),
                    "classes" => $section->getClasses(),
                    "data" => $section->getData(),
                    "writables" => $section->getWritables(),
                ]
            );
    }
1036416
public function setFieldType($field, Type $type) {
    $this->types->set($this->getKey($field), $type);
    return $this;
  }
389278
public function addFields(array $fields)
    {
        foreach ($fields as $field) {
            if (!$field instanceof FieldDefinitionInterface) {
                continue;
            }

            $this->addField($field);
        }

        return $this;
    }
204557
private function addFieldToQuery(
        array $fields = null,
        array $relate = null,
        FullyQualifiedClassName $section
    ): void {

        if (!empty($fields)) {

            $className = lcfirst((string) $section->getClassName());
            foreach ($fields as $handle=>$fieldValue) {

                $sectionEntity = (string) $section;
                $fields = $sectionEntity::fieldInfo();
                $sectionEntityClass = lcfirst((string) $section->getClassName());

                $joinOne = $this->isOneRelationship($handle, $fields);
                $joinMany = $this->isManyRelationship($handle, $fields);

                // If we are dealing with a ONE relationship, join the table first
                if (!is_null($joinOne) && !is_null($relate)) {
                    $this->addJoinOne($joinOne, $sectionEntityClass, $handle, $fieldValue, $relate);
                }

                // If we are dealing with a MANY relationship, join the table first
                if (!is_null($joinMany)) {
                    $this->addJoinMany($joinMany, $sectionEntityClass, $handle, $fieldValue, $relate);
                }

                // If not a relationship, or not a related one relationship (so it's a regular field or a one field)
                if ((is_null($joinOne) && is_null($joinMany)) || is_null($relate)) {

                    // If we have multiple field values, make an IN query
                    if (is_array($fieldValue)) {

                        $addOrNull = false;
                        if ($key = array_search('null', $fieldValue) !== false) {
                            $addOrNull = true;
                            unset($fieldValue[$key]);
                        }

                        $this->queryBuilder->andWhere(
                            $this->queryBuilder->expr()->in(
                                (string) $className . '.' . (string) $handle,
                                ':' . $handle
                            )
                        );

                        if ($addOrNull) {
                            $this->queryBuilder->orWhere((string)$className . '.' . (string)$handle . ' IS NULL');
                        }
                        $this->queryBuilder->setParameter($handle, $fieldValue);

                        // Otherwise, just make a where query
                    } else {
                        if (is_null($fieldValue) || $fieldValue === 'null') {
                            $assign = ' IS NULL';
                            $fieldValue = null;
                        } else {
                            $assign = '= :' . $handle;
                        }

                        $this->queryBuilder->andWhere((string) $className . '.' . (string) $handle . $assign);
                        if (!is_null($fieldValue)) {
                            $this->queryBuilder->setParameter($handle, (string) $fieldValue);
                        }
                    }
                }
            }
        }
    }
928702
public function addGroup($code, $fields = array()) {
        $fields['STRING_ID'] = $code;
        $this->checkRequiredKeys(__METHOD__, $fields, array('STRING_ID', 'NAME'));

        $group = new \CGroup;
        $groupId = $group->Add($this->prepareFields($fields));

        if ($groupId) {
            return intval($groupId);
        }

        $this->throwException(__METHOD__, $group->LAST_ERROR);
    }
795614
private function buildSectionFilterParameters(ParameterBuilderInterface $builder, array $groups = []): void
    {
        $builder->add(
            'filter_by_section',
            ParameterType\Compound\BooleanType::class,
            [
                'groups' => $groups,
            ]
        );

        $builder->get('filter_by_section')->add(
            'sections',
            EzParameterType\SectionType::class,
            [
                'multiple' => true,
                'groups' => $groups,
            ]
        );
    }
582011
public function addField(FormField $field)
    {
        if ($this->fields->contains($field) === false) {
            $field->setForm($this);
            $this->fields->add($field);
        }

        return $this;
    }
685356
public function field(string $fieldHandle, string $value): SectionTwigExtension
    {
        $this->options[ReadOptions::FIELD] = [$fieldHandle=>$value];

        return $this;
    }
669987
protected function setPostCommand(SectionInterface $section, array $definition)
    {
        if (isset($definition[static::CONFIG_POST_COMMAND])) {
            $section->setPostCommand($definition[static::CONFIG_POST_COMMAND]);
        }
    }
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;
    }
837355
public void addGroupFieldSet(String group, CmsFieldSet fieldSet) {

        // can't add a group field set twice
        if (!m_groupFieldSets.containsKey(group)) {
            m_groupFieldSets.put(group, fieldSet);
            m_panel.add(fieldSet);
        }
    }
728541
protected function addContentTypeFieldsToForm($contentTypeFields, FormInterface $form)
    {
        /** @var FieldTypeInterface $contentTypeField */
        foreach ($contentTypeFields as $contentTypeField) {

            if (isset($this->fieldTypesConfiguration[$contentTypeField->getType()])) {
                $this->addFieldToForm($contentTypeField, $form);
            }
        }
    }
1081565
public function addField(Element\AbstractElement $field)
    {
        if (!isset($this->fields[$this->current])) {
            $this->fields[$this->current] = [];
        }
        $this->fields[$this->current][$field->getName()] = $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;
    }
392926
public function add($field, SectionInterface $section = null): MetaboxInterface
    {
        if ($field instanceof SectionInterface) {
            $section = $field;

            if ($section->hasItems()) {
                foreach ($section->getItems() as $item) {
                    /** @var FieldTypeInterface $item */
                    $item->setOptions([
                        'group' => $section->getId()
                    ]);

                    $this->add($item, $section);
                }
            }

            return $this;
        }

        $field->setLocale($this->getLocale());
        $field->setPrefix($this->getPrefix());

        if (is_null($section)) {
            if ($this->repository()->hasGroup($field->getOption('group'))) {
                $section = $this->repository()->getGroup($field->getOption('group'));
            } else {
                $section = new Section($field->getOption('group'));
            }
            $section->addItem($field);
        }

        $this->repository()->addField($field, $section);

        return $this;
    }