Adds the constraints option to the field options.

@param array $options
@param array $formFieldConfiguration
189203
private function addFieldConstraintOptions(array &$options, array $formFieldConfiguration)
    {
        if ($options['required'] === true) {
            $options['constraints'][] = new NotBlank();
        }

        if (isset($formFieldConfiguration['validators'])) {
            $options['constraints'] = array();
            foreach ($formFieldConfiguration['validators'] as $validatorClass => $validatorOptions) {
                $options['constraints'][] = new $validatorClass($validatorOptions);
            }
        }
    }
8830
public function buildView(FormView $view, FormInterface $form, array $options)
    {
        $view->vars['configs'] = $options['configs']; 
        
        // Adds a custom block prefix
        array_splice(
            $view->vars['block_prefixes'],
            array_search($this->getName(), $view->vars['block_prefixes']),
            0,
            'thrace_select2'
        );
    }
1323283
private function validateOptions(array $options, $type)
    {
        if (!isset(self::$requiredOptions[$type])) {
            return;
        }
        foreach (self::$requiredOptions[$type] as $requiredOption) {
            if (!array_key_exists($requiredOption, $options)) {
                throw new ConfigurationException(
                    sprintf('Option "%s" must be provided for "%s" type parameters.', $requiredOption, $type)
                );
            }
        }
    }
152890
public function buildView(FormView $view, FormInterface $form, array $options)
    {
        if ($form->get('content')->isDisabled()) {
            $form->get('content')->addError(new FormError('calendar.error.all_calendars_selected'));
        } elseif (count($this->choices) == 0) {
            $form->get('content')->addError(new FormError('calendar.error.no_calendars_found'));
        }
    }
163817
public function addOptions(array $options)
    {
        $this->options = array_merge($this->options, $options);

        $this->getDefinitionLoader()->setOptions($options);
    }
124912
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $this->addWalletType($builder, $options[SubFormInterface::OPTIONS_FIELD_NAME][static::OPTION_WALLET_CHOICES]);
    }
641360
protected function prepareOptions(array $options = [])
    {
        $helper = $this->formHelper;
        $rulesParser = $helper->createRulesParser($this);
        $rules = $this->getOption('rules');
        $parsedRules = $rules ? $rulesParser->parse($rules) : [];

        $this->options = $helper->mergeOptions($this->options, $options);

        foreach (['attr', 'label_attr', 'wrapper'] as $appendable) {
            // Append values to the 'class' attribute
            if ($this->getOption("{$appendable}.class_append")) {
                // Combine the current class attribute with the appends
                $append = $this->getOption("{$appendable}.class_append");
                $classAttribute = $this->getOption("{$appendable}.class", '').' '.$append;
                $this->setOption("{$appendable}.class", $classAttribute);

                // Then remove the class_append option to prevent it from showing up as an attribute in the HTML
                $this->setOption("{$appendable}.class_append", null);
            }
        }

        if ($this->getOption('attr.multiple') && !$this->getOption('tmp.multipleBracesSet')) {
            $this->name = $this->name.'[]';
            $this->setOption('tmp.multipleBracesSet', true);
        }

        if ($this->parent->haveErrorsEnabled()) {
            $this->addErrorClass();
        }

        if ($this->getOption('required') === true || isset($parsedRules['required'])) {
            $lblClass = $this->getOption('label_attr.class', '');
            $requiredClass = $this->getConfig('defaults.required_class', 'required');

            if (! Str::contains($lblClass, $requiredClass)) {
                $lblClass .= ' '.$requiredClass;
                $this->setOption('label_attr.class', $lblClass);
            }

            if ($this->parent->clientValidationEnabled()) {
                $this->setOption('attr.required', 'required');
            }
        }

        if ($this->parent->clientValidationEnabled() && $parsedRules) {
            $attrs = $this->getOption('attr') + $parsedRules;
            $this->setOption('attr', $attrs);
        }

        $this->setOption('wrapperAttrs', $helper->prepareAttributes($this->getOption('wrapper')));
        $this->setOption('errorAttrs', $helper->prepareAttributes($this->getOption('errors')));

        if ($this->getOption('help_block.text')) {
            $this->setOption(
                'help_block.helpBlockAttrs',
                $helper->prepareAttributes($this->getOption('help_block.attr'))
            );
        }

        return $this->options;
    }
1074956
public function setUpConstraints(&$options)
    {
        $constraints = $this->validator->arrayGet($options, 'constraints');
        $model       = $this->config->getDataModel();

        //set up and check the constraints
        if (is_array($constraints) && sizeof($constraints)) {
            $validConstraints = array();

            //iterate over the constraints and only include the valid ones
            foreach ($constraints as $field => $rel) {
                //check if the supplied values are strings and that their methods exist on their respective models
                if (is_string($field) && is_string($rel) && method_exists($model, $field)) {
                    $validConstraints[$field] = $rel;
                }
            }

            $options['constraints'] = $validConstraints;
        }
    }
779702
protected function configureFormFields(FormMapper $form)
    {
        if ($this->getSubject() == null || $this->getSubject()->getId() === null) {
            $form->add('path', 'text', array('mapped' => false));
        }
        $form->add('alias', 'text');
        $form->add('title', 'text');
        $form->add('keywords', 'text');
        $form->add('description', 'textarea', array());
        $form->add('metatags', 'textarea', array('label' => 'additional metatags'));
        $form->setHelps(array('metatags' => 'help.metatags'));
    }
1191046
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $entityAlias = $this->entityConfiguration['alias'];
        $entityIdGetter = $this->entityConfiguration['idGetter'];

        $fieldOptions = $this
            ->formConfig
            ->getOptions();

        $fieldType = $this
            ->formConfig
            ->getType()
            ->getName();

        foreach ($this->locales as $locale) {
            $translatedFieldName = $locale . '_' . $this->fieldName;

            $entityId = $this->entity->$entityIdGetter();
            $translationData = $entityId
                ? $this
                    ->entityTranslationProvider
                    ->getTranslation(
                        $entityAlias,
                        $entityId,
                        $this->fieldName,
                        $locale
                    )
                : '';

            $builder->add($translatedFieldName, $fieldType, [
                'required' => isset($fieldOptions['required'])
                    ? $this->evaluateRequired(
                        $fieldOptions['required'],
                        $locale
                    )
                    : false,
                'mapped' => false,
                'label' => $fieldOptions['label'],
                'data' => $translationData,
                'constraints' => $fieldOptions['constraints'],
            ]);
        }
    }
819138
public function create($formType, InputInterface $input, array $options = [])
    {
        $options = $this->addDefaultOptions($options);

        $formBuilder = $this->formFactory->createBuilder(FormUtil::formTypeToString($formType), null, $options);

        foreach ($formBuilder as $name => $childBuilder) {
            /* @var FormBuilderInterface $childBuilder */
            if (!$input->hasOption($name)) {
                continue;
            }

            $providedValue = $input->getOption($name);
            if ($providedValue === null) {
                continue;
            }

            $childBuilder->setData($providedValue);
        }

        return $formBuilder->getForm();
    }
615453
protected function setDefaultOptions(array $options = [])
    {
        $this->options = $this->formHelper->mergeOptions($this->allDefaults(), $this->getDefaults());
        $this->options = $this->prepareOptions($options);

        $defaults = $this->setDefaultClasses($options);
        $this->options = $this->formHelper->mergeOptions($this->options, $defaults);

        $this->setupLabel();
    }
1356549
public function addOptions($fieldOptions)
    {
        foreach ($fieldOptions as $type => $value) {
            $this->addOption($type, $value);
        }

        return $this;
    }
492522
protected function loadOptionsFromArray(
        HTML_QuickForm2_Element_Select_OptionContainer $container, $options
    )
    {
        foreach ($options as $key => $value) {
            if (is_array($value)) {
                $optgroup = $container->addOptgroup($key);
                $this->loadOptionsFromArray($optgroup, $value);
            } else {
                $container->addOption($value, $key);
            }
        }
    }
434269
protected function removeFieldsValidationConfiguration(array &$formConfiguration)
    {
        foreach ($formConfiguration['fields'] as $fieldName => $fieldConfiguration) {
            if (true === isset($fieldConfiguration['validation'])) {
                unset($fieldConfiguration['validation']);
                unset($fieldConfiguration['activation']);
                $formConfiguration['fields'][$fieldName] = $fieldConfiguration;
            }
        }

        return $this;
    }
1186813
public function addValueConstraint($fieldType, $value, $constraint)
    {
        $validatorName = $this->getFieldValidator($fieldType);
        $validatorParent = $validatorName . 'Validator';
        if ($this->fieldConstructionObject['fieldType']->validatorConfiguration == null) {
            $this->fieldConstructionObject['fieldType']->validatorConfiguration = array(
                $validatorParent => array(),
            );
        }
        $value = is_numeric($value) ? $value + 0 : $value;

        $this->fieldConstructionObject['fieldType']
            ->validatorConfiguration[$validatorParent][$constraint . $validatorName] = $value;
    }
56460
private function getFieldType(array $formFieldConfiguration, array $fieldConfiguration)
    {
        if (isset($formFieldConfiguration['fieldtype'])) {
            return $formFieldConfiguration['fieldtype'];
        }

        $fieldType = null;
        switch ($fieldConfiguration['datatype']) {
            case 'BOOLEAN':
                $fieldType = CheckboxType::class;
                break;
            case 'DATE':
                $fieldType = DateType::class;
                break;
            case 'DATEINTERVAL':
                $fieldType = TextType::class;
                break;
            case 'DATETIME':
                $fieldType = DateTimeType::class;
                break;
            case 'DECIMAL':
                $fieldType = NumberType::class;
                break;
            case 'FILE':
                $fieldType = FileType::class;
                break;
            case 'FLOAT':
                $fieldType = NumberType::class;
                break;
            case 'INTEGER':
                $fieldType = IntegerType::class;
                break;
            case 'SET':
                $fieldType = ChoiceType::class;
                break;
            case 'TEXT':
            case 'HTML':
            case 'JSON':
                $fieldType = TextareaType::class;
                break;
            case 'VARCHAR':
                $fieldType = TextType::class;
                break;
        }

        if (isset($formFieldConfiguration['options']) || isset($fieldConfiguration['options'])) {
            $fieldType = ChoiceType::class;
        }

        return $fieldType;
    }