Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit94fe8dc

Browse files
committed
Add info about callback in options resolver
1 parent6c3d9eb commit94fe8dc

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

‎components/options_resolver.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,26 @@ There is also an
305305
method, which you can use if you want to add an allowed value to the previously
306306
set allowed values.
307307

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+
308328
Configure allowed Types
309329
~~~~~~~~~~~~~~~~~~~~~~~
310330

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp