Inherited options:
max_length
required
label
trim
read_only
error_bubbling
@param \Symfony\Component\OptionsResolver\OptionsResolverInterface $resolver
769854
public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        parent::setDefaultOptions($resolver);

        $resolver
            ->setDefaults(array(
                // ATOM/W3C
                'input' => 'string',
                'format' => \IntlDateFormatter::MEDIUM,
                'widget' => 'single_text'
        ));
    }
584615
public function configureOptions(OptionsResolver $resolver)
    {
        $resolver
            // filter option is required
            ->setRequired('filters')
            ->setAllowedTypes('filters', 'array')

            // sources is required and should be an array
            ->setRequired('sources')
            ->setAllowedTypes('sources', 'array')

            // destination should be a string, no array is allowed for now
            ->setRequired('destinations')
            ->setAllowedTypes('destinations', 'array')

            // debug mode (allow more verbosity)
            ->setDefault('debug', false)
            ->setAllowedTypes('debug', 'boolean')
        ;
    }
506584
public function configureOptions(OptionsResolver $resolver)
    {
        $that = $this;

        if (!interface_exists(ChoiceLoaderInterface::class)) {
            $resolver->setDefaults([
                'context' => null,
                'category' => null,
                'choice_list' => static function (Options $opts, $previousValue) use ($that) {
                    return new SimpleChoiceList($that->getChoices($opts));
                },
            ]);

            return;
        }
        $resolver->setDefaults([
            'context' => null,
            'category' => null,
            'choice_loader' => static function (Options $opts, $previousValue) use ($that) {
                return new CategoryChoiceLoader(array_flip($that->getChoices($opts)));
            },
        ]);
    }
1347089
private function configureOptions(OptionsResolver $optionsResolver)
    {
        $optionsResolver
            ->setRequired([
                'language',
                'contentType',
            ])
            ->setDefined(['baseLanguage'])
            ->setAllowedTypes('contentType', ContentType::class)
            ->setAllowedTypes('baseLanguage', ['null', Language::class])
            ->setAllowedTypes('language', Language::class);
    }
578187
protected function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setRequired(
            array(
                'file',
                'document_columns',
                'category_column'
            )
        );

        $resolver->setOptional(
            array(
                'limit',
                'delimiter',
                'enclosure',
                'escape',
                'category_modifier'
            )
        );

        $resolver->setDefaults(
            array(
                'limit' => false,
                'length' => 0,
                'delimiter' => ',',
                'enclosure' => '"',
                'escape' => '\\',
                'category_modifier' => false
            )
        );

        $resolver->setAllowedTypes(
            array(
                'file' => 'string',
                'document_columns' => 'array',
                'category_column' => 'string',
                'length' => 'int',
                'delimiter' => 'string',
                'enclosure' => 'string',
                'escape' => 'string'
            )
        );
    }
1320177
protected function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setRequired('content');
        $resolver->setAllowedTypes('content', SiteContent::class);

        $resolver->setDefined('exclude_self');
        $resolver->setAllowedTypes('exclude_self', ['bool']);
        $resolver->setDefaults([
            'exclude_self' => true,
        ]);
    }
142576
protected function configureIntegerProperty($property, OptionsResolver $resolver)
    {
        $resolver
            ->setAllowedTypes($property, ['integer', 'numeric'])
            ->setNormalizer($property, function (Options $options, $value) {
                return is_int($value) ? $value : intval($value);
            });
    }
14789
public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $defaultConfigs = array();
        
        $resolver->setDefaults(array(
            'translation_domain' => 'ThraceFormBundle',
            'by_reference' => false,
            'configs' => $defaultConfigs,
        ));
        
        $resolver->setNormalizers(array(
            'configs' => function (Options $options, $value) use ($defaultConfigs){
                $configs = array_replace_recursive($defaultConfigs, $value);
                return $configs;
            }
        ));
          
        $resolver->setRequired(array('reference_class', 'inversed_class', 'inversed_property'));
    }
686187
public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefault('synapse_form_options', array());

        $resolver->setDefined(array('synapse_theme'));
        $resolver->setNormalizer('synapse_theme', function (Options $options, $value) {
            switch (true) {
                case empty($value):
                    return $value;

                case $value instanceof Theme:
                    return $value;

                default:
                    if (!$theme = $this->themeLoader->retrieveByName($value)) {
                        throw new InvalidThemeException(sprintf(
                            'Theme "%s" not registered. Only %s are, check your configuration.',
                            $value,
                            $this->themeLoader->retrieveAll()->display('name')
                        ));
                    }

                    return $theme;
            }
        });
    }
499397
public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $defaultConfigs = $this->options;
    
        $resolver->setDefaults(array(
            'translation_domain' => 'ThraceFormBundle',
            'configs' => $defaultConfigs          
        ));
        
        $resolver->setNormalizers(array(
            'configs' => function (Options $options, $value) use ($defaultConfigs){
                $configs = array_replace_recursive($defaultConfigs, $value);

                return $configs;
            }
        ));
    }
714926
protected function configureAdditionalImage(OptionsResolver $resolver)
    {
        $resolver
            ->setRequired(['prefix', 'width', 'height'])
            ->setOptional(['mode'])
            ->setDefaults(['mode' => 'fit'])
            ->addAllowedTypes(
                [
                    'prefix' => 'string',
                    'mode' => 'string',
                    'width' => 'integer',
                    'height' => 'integer',
                ]
            )
            ->addAllowedValues(['mode' => ['crop', 'resize', 'fit']]);

        return $this;
    }
109277
public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(
            [
                'route' => null,
                'route_parameters' => [],
                'uri' => null,
                'attr' => [
                    'class' => 'btn btn-default btn-light',
                ],
            ]
        );
        $resolver->setAllowedTypes('route_parameters', 'array');
        $resolver->setNormalizer(
            'route',
            function (Options $options, $value) {
                if (!($value xor $options['uri'])) {
                    throw new \UnexpectedValueException("You must specify either a 'route' or an 'uri' option");
                }

                return $value;
            }
        );
    }
1119310
public function configureOptions(OptionsResolver $resolver)
    {
        $resolver
            ->setDefaults([
                'title' => null,
                'class' => Action::class,
                'fields' => [],
                'permissions' => [
                    'ROLE_ADMIN',
                ],
                'export' => [],
                'order' => [],
                'route' => $this->generateRouteName(),
                'route_parameters' => [],
                'route_path' => $this->getDefaultRoutePath(),
                'route_requirements' => [],
                'route_defaults' => [
                    '_controller' => AdminAction::class,
                ],
                'icon' => null,
                'load_strategy' => LAGAdminBundle::LOAD_STRATEGY_NONE,
                'pager' => $this->adminConfiguration->getParameter('pager'),
                'page_parameter' => $this->adminConfiguration->getParameter('page_parameter'),
                'max_per_page' => 30,
                'criteria' => [],
                'filters' => [],
                'menus' => [],
                'template' => $this->getDefaultTemplate(),
                'sortable' => false,
                'string_length' => $this->adminConfiguration->getParameter('string_length'),
                'string_length_truncate' => $this->adminConfiguration->getParameter('string_length_truncate'),
                'date_format' => $this->adminConfiguration->getParameter('date_format'),
                'use_form' => true,
                'form' => null,
            ])
            ->setAllowedTypes('title', [
                'string',
                'null',
            ])
            ->setAllowedTypes('class', 'string')
            ->setAllowedTypes('fields', 'array')
            ->setAllowedTypes('permissions', 'array')
            ->setAllowedTypes('export', 'array')
            ->setAllowedTypes('order', 'array')
            ->setAllowedTypes('route', 'string')
            ->setAllowedTypes('route_parameters', 'array')
            ->setAllowedTypes('route_path', 'string')
            ->setAllowedTypes('route_defaults', 'array')
            ->setAllowedTypes('route_requirements', 'array')
            ->setAllowedTypes('string_length', 'integer')
            ->setAllowedTypes('string_length_truncate', 'string')
            ->setNormalizer('fields', $this->getFieldsNormalizer())
            ->setNormalizer('order', $this->getOrderNormalizer())
            ->setNormalizer('load_strategy', $this->getLoadStrategyNormalizer())
            ->setNormalizer('criteria', $this->getCriteriaNormalizer())
            ->setNormalizer('menus', $this->getMenuNormalizer())
            ->setNormalizer('filters', $this->getFiltersNormalizer())
            ->setNormalizer('route_defaults', $this->getRouteDefaultNormalizer())
            ->setNormalizer('form', $this->getFormNormalizer())
            ->setNormalizer('title', $this->getTitleNormalizer())
            ->setAllowedValues('load_strategy', [
                LAGAdminBundle::LOAD_STRATEGY_NONE,
                LAGAdminBundle::LOAD_STRATEGY_UNIQUE,
                LAGAdminBundle::LOAD_STRATEGY_MULTIPLE,
            ])
            ->setAllowedValues('pager', [
                'pagerfanta',
                false,
                null,
            ])
        ;
    }
1074065
public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(
            [
                'choices' => null,
                'families' => null,
            ]
        );

        $resolver->setNormalizer(
            'families',
            function (Options $options, $values) {
                if (null === $values) {
                    $values = $this->familyRegistry->getFamilies();
                }
                $families = [];
                foreach ($values as $value) {
                    if (!$value instanceof FamilyInterface) {
                        $value = $this->familyRegistry->getFamily($value);
                    }
                    if ($value->isInstantiable()) {
                        $families[$value->getCode()] = $value;
                    }
                }

                return $families;
            }
        );
        $resolver->setNormalizer(
            'choices',
            function (Options $options, $value) {
                if (null !== $value) {
                    throw new \UnexpectedValueException(
                        "'choices' options is not supported for family selector, please use 'families' option"
                    );
                }
                $choices = [];
                /** @var FamilyInterface[] $families */
                $families = $options['families'];
                $duplicates = [];
                foreach ($families as $family) {
                    if ($family->isInstantiable()) {
                        $label = ucfirst($family);
                        if (array_key_exists($label, $choices)) {
                            // Storing duplicates
                            $duplicates[] = $label;
                            $label = "{$label} ({$family->getCode()})";
                        }
                        $choices[$label] = $family->getCode();
                    }
                }

                // Recreating duplicates
                foreach ($duplicates as $duplicate) {
                    $choices["{$duplicate} ({$choices[$duplicate]})"] = $choices[$duplicate];
                    unset($choices[$duplicate]);
                }
                ksort($choices);

                return $choices;
            }
        );
    }
879147
public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver
            ->setRequired(array(
                'field'
            ))
            ->setOptional(array(
                'sobject_type',
                'fieldname',
                'recordtype_id'
            ))
            ->setDefaults(array(
                'recordtype_id' => null,
                'field' => $this->fieldOption,
                'sobject_type' => function(Options $options)
                {
                    return $options['field']->getSobjectType();
                },
                'fieldname' => function(Options $options)
                {
                    return $options['field']->getName();
                },
                'field_type' => function(Options $options)
                {
                    return $options['field']->getType();
                },
                'required' => function(Options $options, $previous)
                {
                    if(null !== ($req= $options['field']->getRequired()))
                    {
                        return $req;
                    }
                    return $previous;
                },
                'label' => function(Options $options, $previous)
                {
                    if(null !== ($label = $options['field']->getLabel()))
                    {
                        return $label;
                    }
                    return $previous;
                },
                'read_only' => function(Options $options, $previous)
                {
                    if(null !== ($readonly = $options['field']->getReadonly()))
                    {
                        return $readonly;
                    }
                    return $previous;
                }
            ));
    }
177552
public function configureOptions (OptionsResolver $resolver)
    {
        $allRoles = $this->roleCollection->getAllAvailableRoles();
        $allRoleKeys = array_keys($allRoles);

        $resolver->setDefaults([
            "roles_with_tags" => [],
            "choices" => function(Options $options) use ($allRoleKeys, $allRoles)
            {
                // if no tags are selected, just return all roles
                if (empty($options["roles_with_tags"]))
                {
                    return array_combine($allRoleKeys, $allRoleKeys);
                }

                // if tags are selected, only use the choices with the given tags
                $choices = [];

                foreach ($allRoles as $roleKey => $role)
                {
                    if (!empty(array_intersect($options["roles_with_tags"], $role->getTags())))
                    {
                        $choices[$roleKey] = $roleKey;
                    }
                }

                return $choices;
            },
            "choices_as_values" => true,
            "choice_label" => function ($choiceValue, $choiceKey, $index) use ($allRoles)
            {
                return $allRoles[$choiceKey]->getTitle();
            },
            "choice_attr" => function ($choiceValue, $choiceKey, $index) use ($allRoles)
            {
                return [
                    "data-role-description" => $allRoles[$choiceKey]->getDescription(),
                ];
            },
        ]);

        $resolver->setAllowedTypes("roles_with_tags", ["array"]);
    }
105595
public function addFormFieldResolver(FormFieldResolverInterface $resolver, $priority = 0)
    {
        $this->formFieldResolvers[$priority][] = $resolver;
        $this->needsSorting = true;
    }