File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ option.
19
19
| | - `expanded `_ |
20
20
| | - `preferred_choices `_ |
21
21
| | - `empty_value `_ |
22
+ | | - `empty_data `_ |
22
23
+-------------+-----------------------------------------------------------------------------+
23
24
| Inherited | - `required `_ |
24
25
| options | - `label `_ |
@@ -101,6 +102,8 @@ can be created to supply the choices.
101
102
102
103
.. include :: /reference/forms/types/options/empty_value.rst.inc
103
104
105
+ .. include :: /reference/forms/types/options/empty_data.rst.inc
106
+
104
107
Inherited options
105
108
-----------------
106
109
Original file line number Diff line number Diff line change
1
+ empty_data
2
+ ~~~~~~~~~~
3
+
4
+ **type**: ``mixed`` **default**: ``array()`` if ``multiple`` or ``expanded``, ``''`` otherwise
5
+
6
+ This option determines what value the field will return when the ``empty_value``
7
+ choice is selected.
8
+
9
+ For example, if you want the ``gender`` field to be set to ``null`` when no
10
+ value is selected, you can do it like this:
11
+
12
+ .. code-block:: php
13
+
14
+ $builder->add('gender', 'choice', array(
15
+ 'choices' => array(
16
+ 'm' => 'Male',
17
+ 'f' => 'Female'
18
+ ),
19
+ 'required' => false,
20
+ 'empty_value' => 'Choose your gender',
21
+ 'empty_data' => null
22
+ ));
You can’t perform that action at this time.
0 commit comments