File tree Expand file tree Collapse file tree 10 files changed +54
-18
lines changed Expand file tree Collapse file tree 10 files changed +54
-18
lines changed Original file line number Diff line number Diff line change @@ -81,12 +81,12 @@ These options inherit from the :doc:`FormType </reference/forms/types/form>`:
8181
8282.. include :: /reference/forms/types/options/disabled.rst.inc
8383
84- .. include :: /reference/forms/types/options/empty_data .rst.inc
84+ .. include :: /reference/forms/types/options/text_empty_data .rst.inc
8585 :end-before: DEFAULT_PLACEHOLDER
8686
8787The default value is ``'' `` (the empty string).
8888
89- .. include :: /reference/forms/types/options/empty_data .rst.inc
89+ .. include :: /reference/forms/types/options/text_empty_data .rst.inc
9090 :start-after: DEFAULT_PLACEHOLDER
9191
9292.. include :: /reference/forms/types/options/error_bubbling.rst.inc
Original file line number Diff line number Diff line change @@ -56,12 +56,12 @@ 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 .rst.inc
59+ .. include :: /reference/forms/types/options/text_empty_data .rst.inc
6060 :end-before: DEFAULT_PLACEHOLDER
6161
6262The default value is ``'' `` (the empty string).
6363
64- .. include :: /reference/forms/types/options/empty_data .rst.inc
64+ .. include :: /reference/forms/types/options/text_empty_data .rst.inc
6565 :start-after: DEFAULT_PLACEHOLDER
6666
6767.. include :: /reference/forms/types/options/error_bubbling.rst.inc
Original file line number Diff line number Diff line change 1+ ``empty_data``
2+ ~~~~~~~~~~~~~~
3+
4+ **type **: ``mixed``
5+
6+ .. This file should only be included with start-after or end -before that' s
7+ set to this placeholder value. Its purpose is to let us include only
8+ part of this file.
9+
10+ DEFAULT_PLACEHOLDER
11+
12+ This option determines what value the field will *return* when the submitted
13+ value is empty (or missing). It does not set an initial value if none is
14+ provided when the form is rendered in a view.
15+
16+ This means it helps you handling form submission with blank fields. For
17+ example, if you want the ``name`` field to be explicitly set to ``John Doe``
18+ when no value is selected, you can do it like this::
19+
20+ $builder->add(' name ' , null, [
21+ ' required' => false,
22+ ' empty_data' => ' John Doe' ,
23+ ]);
24+
25+ This will still render an empty text box, but upon submission the ``John Doe``
26+ value will be set. Use the ``data`` or ``placeholder`` options to show this
27+ initial value in the rendered form.
28+
29+ If a form is compound, you can set ``empty_data`` as an array, object or
30+ closure. See the :doc:`/form/use_empty_data` article for more details about
31+ these options.
32+
33+ .. note::
34+
35+ If you want to set the ``empty_data`` option for your entire form class,
36+ see the :doc:`/form/use_empty_data` article.
Original file line number Diff line number Diff line change @@ -79,12 +79,12 @@ These options inherit from the :doc:`FormType </reference/forms/types/form>`:
7979
8080.. include :: /reference/forms/types/options/disabled.rst.inc
8181
82- .. include :: /reference/forms/types/options/empty_data .rst.inc
82+ .. include :: /reference/forms/types/options/text_empty_data .rst.inc
8383 :end-before: DEFAULT_PLACEHOLDER
8484
8585The default value is ``'' `` (the empty string).
8686
87- .. include :: /reference/forms/types/options/empty_data .rst.inc
87+ .. include :: /reference/forms/types/options/text_empty_data .rst.inc
8888 :start-after: DEFAULT_PLACEHOLDER
8989
9090.. include :: /reference/forms/types/options/error_bubbling.rst.inc
Original file line number Diff line number Diff line change @@ -70,12 +70,12 @@ These options inherit from the :doc:`FormType </reference/forms/types/form>`:
7070
7171.. include :: /reference/forms/types/options/disabled.rst.inc
7272
73- .. include :: /reference/forms/types/options/empty_data .rst.inc
73+ .. include :: /reference/forms/types/options/text_empty_data .rst.inc
7474 :end-before: DEFAULT_PLACEHOLDER
7575
7676The default value is ``'' `` (the empty string).
7777
78- .. include :: /reference/forms/types/options/empty_data .rst.inc
78+ .. include :: /reference/forms/types/options/text_empty_data .rst.inc
7979 :start-after: DEFAULT_PLACEHOLDER
8080
8181.. include :: /reference/forms/types/options/error_bubbling.rst.inc
Original file line number Diff line number Diff line change @@ -55,12 +55,12 @@ These options inherit from the :doc:`FormType </reference/forms/types/form>`:
5555
5656.. include :: /reference/forms/types/options/disabled.rst.inc
5757
58- .. include :: /reference/forms/types/options/empty_data .rst.inc
58+ .. include :: /reference/forms/types/options/text_empty_data .rst.inc
5959 :end-before: DEFAULT_PLACEHOLDER
6060
6161The default value is ``'' `` (the empty string).
6262
63- .. include :: /reference/forms/types/options/empty_data .rst.inc
63+ .. include :: /reference/forms/types/options/text_empty_data .rst.inc
6464 :start-after: DEFAULT_PLACEHOLDER
6565
6666.. include :: /reference/forms/types/options/error_bubbling.rst.inc
Original file line number Diff line number Diff line change @@ -62,12 +62,12 @@ These options inherit from the :doc:`FormType </reference/forms/types/form>`:
6262
6363.. include :: /reference/forms/types/options/disabled.rst.inc
6464
65- .. include :: /reference/forms/types/options/empty_data .rst.inc
65+ .. include :: /reference/forms/types/options/text_empty_data .rst.inc
6666 :end-before: DEFAULT_PLACEHOLDER
6767
6868The default value is ``'' `` (the empty string).
6969
70- .. include :: /reference/forms/types/options/empty_data .rst.inc
70+ .. include :: /reference/forms/types/options/text_empty_data .rst.inc
7171 :start-after: DEFAULT_PLACEHOLDER
7272
7373.. include :: /reference/forms/types/options/error_bubbling.rst.inc
Original file line number Diff line number Diff line change @@ -47,14 +47,14 @@ These options inherit from the :doc:`FormType </reference/forms/types/form>`:
4747
4848.. include :: /reference/forms/types/options/disabled.rst.inc
4949
50- .. include :: /reference/forms/types/options/empty_data .rst.inc
50+ .. include :: /reference/forms/types/options/text_empty_data .rst.inc
5151 :end-before: DEFAULT_PLACEHOLDER
5252
5353From an HTTP perspective, submitted data is always a string or an array of strings.
5454So by default, the form will treat any empty string as null. If you prefer to get
5555an empty string, explicitly set the ``empty_data `` option to an empty string.
5656
57- .. include :: /reference/forms/types/options/empty_data .rst.inc
57+ .. include :: /reference/forms/types/options/text_empty_data .rst.inc
5858 :start-after: DEFAULT_PLACEHOLDER
5959
6060.. include :: /reference/forms/types/options/error_bubbling.rst.inc
Original file line number Diff line number Diff line change @@ -50,12 +50,12 @@ These options inherit from the :doc:`FormType </reference/forms/types/form>`:
5050
5151.. include :: /reference/forms/types/options/disabled.rst.inc
5252
53- .. include :: /reference/forms/types/options/empty_data .rst.inc
53+ .. include :: /reference/forms/types/options/text_empty_data .rst.inc
5454 :end-before: DEFAULT_PLACEHOLDER
5555
5656The default value is ``'' `` (the empty string).
5757
58- .. include :: /reference/forms/types/options/empty_data .rst.inc
58+ .. include :: /reference/forms/types/options/text_empty_data .rst.inc
5959 :start-after: DEFAULT_PLACEHOLDER
6060
6161.. include :: /reference/forms/types/options/error_bubbling.rst.inc
Original file line number Diff line number Diff line change @@ -71,12 +71,12 @@ These options inherit from the :doc:`FormType </reference/forms/types/form>`:
7171
7272.. include :: /reference/forms/types/options/disabled.rst.inc
7373
74- .. include :: /reference/forms/types/options/empty_data .rst.inc
74+ .. include :: /reference/forms/types/options/text_empty_data .rst.inc
7575 :end-before: DEFAULT_PLACEHOLDER
7676
7777The default value is ``'' `` (the empty string).
7878
79- .. include :: /reference/forms/types/options/empty_data .rst.inc
79+ .. include :: /reference/forms/types/options/text_empty_data .rst.inc
8080 :start-after: DEFAULT_PLACEHOLDER
8181
8282.. include :: /reference/forms/types/options/error_bubbling.rst.inc
You can’t perform that action at this time.
0 commit comments