Skip to content

Commit b1a5bbc

Browse files
committed
[R] components/options_resolver
- Review by @stof
1 parent 38c61fa commit b1a5bbc

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

components/options_resolver.rst

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ The OptionsResolver Component
99
arrays. It supports default values, option constraints and lazy options.
1010

1111
.. versionadded:: 2.1
12-
The OptionsResolver Component is new in Symfony2.1, it can be found in the
13-
Form component in older versions.
12+
The OptionsResolver Component is new in Symfony2.1
1413

1514
Installation
1615
------------
@@ -201,7 +200,7 @@ Default values that depend on another option
201200

202201
If you add a ``gender`` option to the ``Person`` class, it should get a
203202
default value which guess the gender based on the first name. You can do that
204-
easilly by using a Closure as default value::
203+
easily by using a Closure as default value::
205204

206205
use Symfony\Component\OptionsResolver\Options;
207206

@@ -221,6 +220,11 @@ easilly by using a Closure as default value::
221220
));
222221
}
223222

223+
.. caution::
224+
225+
The first argument of the Closure must be typehinted as `Options`,
226+
otherwise it is considered as the value.
227+
224228
Configure allowed values
225229
------------------------
226230

@@ -261,6 +265,11 @@ be anything, but it must be a string. You can configure these types by calling
261265
));
262266
}
263267

268+
Possible types are the one associated with the ``is_*`` php functions or a
269+
class name. You can also pass an array of types as value. For instance,
270+
``array('null', 'string')`` allows ``firstName`` to be ``null`` or a
271+
``string``.
272+
264273
There is also a
265274
:method:`Symfony\\Component\\OptionsResolver\\OptionsResolver::addAllowedTypes`
266275
method, which you can use to add an allowed type to the previous allowed types.

0 commit comments

Comments
 (0)