We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6c3d9eb commit 94fe8dcCopy full SHA for 94fe8dc
components/options_resolver.rst
@@ -305,6 +305,26 @@ There is also an
305
method, which you can use if you want to add an allowed value to the previously
306
set allowed values.
307
308
+If you need to add some more logic to the value validation process you can pass a callable
309
+as an allowed value::
310
+
311
+ // ...
312
+ protected function setDefaultOptions(OptionsResolverInterface $resolver)
313
+ {
314
315
316
+ $resolver->setAllowedValues(array(
317
+ 'transport' => function($value) {
318
+ return strpos($value, 'mail') !== false;
319
+ }
320
+ ));
321
322
323
+Note that using this together with addAllowedValues will not work.
324
325
+.. versionadded:: 2.5
326
+ The callback support for allowed values was added in Symfony 2.5.
327
328
Configure allowed Types
329
~~~~~~~~~~~~~~~~~~~~~~~
330
0 commit comments