File tree Expand file tree Collapse file tree 11 files changed +47
-18
lines changed Expand file tree Collapse file tree 11 files changed +47
-18
lines changed Original file line number Diff line number Diff line change @@ -56,11 +56,11 @@ These options inherit from the :doc:`FormType </reference/forms/types/form>`:
5656
5757.. include :: /reference/forms/types/options/disabled.rst.inc
5858
59- .. include :: /reference/forms/types/options/empty_data_declaration .rst.inc
59+ .. include :: /reference/forms/types/options/text_empty_data_declaration .rst.inc
6060
6161The default value is ``'' `` (the empty string).
6262
63- .. include :: /reference/forms/types/options/empty_data_description .rst.inc
63+ .. include :: /reference/forms/types/options/text_empty_data_description .rst.inc
6464
6565.. include :: /reference/forms/types/options/error_bubbling.rst.inc
6666
Original file line number Diff line number Diff line change @@ -37,11 +37,11 @@ These options inherit from the :doc:`FormType </reference/forms/types/form>`:
3737
3838.. include :: /reference/forms/types/options/disabled.rst.inc
3939
40- .. include :: /reference/forms/types/options/empty_data_declaration .rst.inc
40+ .. include :: /reference/forms/types/options/text_empty_data_declaration .rst.inc
4141
4242The default value is ``'' `` (the empty string).
4343
44- .. include :: /reference/forms/types/options/empty_data_description .rst.inc
44+ .. include :: /reference/forms/types/options/text_empty_data_description .rst.inc
4545
4646.. include :: /reference/forms/types/options/error_bubbling.rst.inc
4747
Original file line number Diff line number Diff line change 1+ ``empty_data``
2+ ~~~~~~~~~~~~~~
3+
4+ **type **: ``mixed``
Original file line number Diff line number Diff line change 1+ This option determines what value the field will *return* when the submitted
2+ value is empty (or missing). It does not set an initial value if none is
3+ provided when the form is rendered in a view.
4+
5+ This means it helps you handling form submission with blank fields. For
6+ example, if you want the ``name`` field to be explicitly set to ``John Doe``
7+ when no value is selected, you can do it like this::
8+
9+ $builder->add('name', null, [
10+ 'required' => false,
11+ 'empty_data' => 'John Doe',
12+ ]);
13+
14+ This will still render an empty text box, but upon submission the ``John Doe``
15+ value will be set. Use the ``data`` or ``placeholder`` options to show this
16+ initial value in the rendered form.
17+
18+ If a form is compound, you can set ``empty_data`` as an array, object or
19+ closure. See the :doc:`/form/use_empty_data` article for more details about
20+ these options.
21+
22+ .. note::
23+
24+ If you want to set the ``empty_data`` option for your entire form class,
25+ see the :doc:`/form/use_empty_data` article.
Original file line number Diff line number Diff line change @@ -59,11 +59,11 @@ These options inherit from the :doc:`FormType </reference/forms/types/form>`:
5959
6060.. include :: /reference/forms/types/options/disabled.rst.inc
6161
62- .. include :: /reference/forms/types/options/empty_data_declaration .rst.inc
62+ .. include :: /reference/forms/types/options/text_empty_data_declaration .rst.inc
6363
6464The default value is ``'' `` (the empty string).
6565
66- .. include :: /reference/forms/types/options/empty_data_description .rst.inc
66+ .. include :: /reference/forms/types/options/text_empty_data_description .rst.inc
6767
6868.. include :: /reference/forms/types/options/error_bubbling.rst.inc
6969
Original file line number Diff line number Diff line change @@ -52,11 +52,11 @@ These options inherit from the :doc:`FormType </reference/forms/types/form>`:
5252
5353.. include :: /reference/forms/types/options/disabled.rst.inc
5454
55- .. include :: /reference/forms/types/options/empty_data_declaration .rst.inc
55+ .. include :: /reference/forms/types/options/text_empty_data_declaration .rst.inc
5656
5757The default value is ``'' `` (the empty string).
5858
59- .. include :: /reference/forms/types/options/empty_data_description .rst.inc
59+ .. include :: /reference/forms/types/options/text_empty_data_description .rst.inc
6060
6161.. include :: /reference/forms/types/options/error_bubbling.rst.inc
6262
Original file line number Diff line number Diff line change @@ -37,11 +37,11 @@ These options inherit from the :doc:`FormType </reference/forms/types/form>`:
3737
3838.. include :: /reference/forms/types/options/disabled.rst.inc
3939
40- .. include :: /reference/forms/types/options/empty_data_declaration .rst.inc
40+ .. include :: /reference/forms/types/options/text_empty_data_declaration .rst.inc
4141
4242The default value is ``'' `` (the empty string).
4343
44- .. include :: /reference/forms/types/options/empty_data_description .rst.inc
44+ .. include :: /reference/forms/types/options/text_empty_data_description .rst.inc
4545
4646.. include :: /reference/forms/types/options/error_bubbling.rst.inc
4747
Original file line number Diff line number Diff line change @@ -43,11 +43,11 @@ These options inherit from the :doc:`FormType </reference/forms/types/form>`:
4343
4444.. include :: /reference/forms/types/options/disabled.rst.inc
4545
46- .. include :: /reference/forms/types/options/empty_data_declaration .rst.inc
46+ .. include :: /reference/forms/types/options/text_empty_data_declaration .rst.inc
4747
4848The default value is ``'' `` (the empty string).
4949
50- .. include :: /reference/forms/types/options/empty_data_description .rst.inc
50+ .. include :: /reference/forms/types/options/text_empty_data_description .rst.inc
5151
5252.. include :: /reference/forms/types/options/error_bubbling.rst.inc
5353
Original file line number Diff line number Diff line change @@ -27,13 +27,13 @@ These options inherit from the :doc:`FormType </reference/forms/types/form>`:
2727
2828.. include :: /reference/forms/types/options/disabled.rst.inc
2929
30- .. include :: /reference/forms/types/options/empty_data_declaration .rst.inc
30+ .. include :: /reference/forms/types/options/text_empty_data_declaration .rst.inc
3131
3232From an HTTP perspective, submitted data is always a string or an array of strings.
3333So by default, the form will treat any empty string as null. If you prefer to get
3434an empty string, explicitly set the ``empty_data `` option to an empty string.
3535
36- .. include :: /reference/forms/types/options/empty_data_description .rst.inc
36+ .. include :: /reference/forms/types/options/text_empty_data_description .rst.inc
3737
3838.. include :: /reference/forms/types/options/error_bubbling.rst.inc
3939
Original file line number Diff line number Diff line change @@ -40,11 +40,11 @@ These options inherit from the :doc:`FormType </reference/forms/types/form>`:
4040
4141.. include :: /reference/forms/types/options/disabled.rst.inc
4242
43- .. include :: /reference/forms/types/options/empty_data_declaration .rst.inc
43+ .. include :: /reference/forms/types/options/text_empty_data_declaration .rst.inc
4444
4545The default value is ``'' `` (the empty string).
4646
47- .. include :: /reference/forms/types/options/empty_data_description .rst.inc
47+ .. include :: /reference/forms/types/options/text_empty_data_description .rst.inc
4848
4949.. include :: /reference/forms/types/options/error_bubbling.rst.inc
5050
You can’t perform that action at this time.
0 commit comments