Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions components/options_resolver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,29 @@ There is also an
method, which you can use if you want to add an allowed value to the previously
set allowed values.

.. versionadded:: 2.5

The callback support for allowed values was introduced in Symfony 2.5.

If you need to add some more logic to the value validation process, you can pass a callable
as an allowed value::

// ...
protected function setDefaultOptions(OptionsResolverInterface $resolver)
{
// ...

$resolver->setAllowedValues(array(
'transport' => function($value) {
return false !== strpos($value, 'mail');
},
));
}

.. caution::

Note that using this together with ``addAllowedValues`` will not work.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addAllowedValues()


Configure allowed Types
~~~~~~~~~~~~~~~~~~~~~~~

Expand Down