File tree 11 files changed +47
-18
lines changed
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>`:
56
56
57
57
.. include :: /reference/forms/types/options/disabled.rst.inc
58
58
59
- .. include :: /reference/forms/types/options/empty_data_declaration .rst.inc
59
+ .. include :: /reference/forms/types/options/text_empty_data_declaration .rst.inc
60
60
61
61
The default value is ``'' `` (the empty string).
62
62
63
- .. include :: /reference/forms/types/options/empty_data_description .rst.inc
63
+ .. include :: /reference/forms/types/options/text_empty_data_description .rst.inc
64
64
65
65
.. include :: /reference/forms/types/options/error_bubbling.rst.inc
66
66
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>`:
37
37
38
38
.. include :: /reference/forms/types/options/disabled.rst.inc
39
39
40
- .. include :: /reference/forms/types/options/empty_data_declaration .rst.inc
40
+ .. include :: /reference/forms/types/options/text_empty_data_declaration .rst.inc
41
41
42
42
The default value is ``'' `` (the empty string).
43
43
44
- .. include :: /reference/forms/types/options/empty_data_description .rst.inc
44
+ .. include :: /reference/forms/types/options/text_empty_data_description .rst.inc
45
45
46
46
.. include :: /reference/forms/types/options/error_bubbling.rst.inc
47
47
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>`:
59
59
60
60
.. include :: /reference/forms/types/options/disabled.rst.inc
61
61
62
- .. include :: /reference/forms/types/options/empty_data_declaration .rst.inc
62
+ .. include :: /reference/forms/types/options/text_empty_data_declaration .rst.inc
63
63
64
64
The default value is ``'' `` (the empty string).
65
65
66
- .. include :: /reference/forms/types/options/empty_data_description .rst.inc
66
+ .. include :: /reference/forms/types/options/text_empty_data_description .rst.inc
67
67
68
68
.. include :: /reference/forms/types/options/error_bubbling.rst.inc
69
69
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>`:
52
52
53
53
.. include :: /reference/forms/types/options/disabled.rst.inc
54
54
55
- .. include :: /reference/forms/types/options/empty_data_declaration .rst.inc
55
+ .. include :: /reference/forms/types/options/text_empty_data_declaration .rst.inc
56
56
57
57
The default value is ``'' `` (the empty string).
58
58
59
- .. include :: /reference/forms/types/options/empty_data_description .rst.inc
59
+ .. include :: /reference/forms/types/options/text_empty_data_description .rst.inc
60
60
61
61
.. include :: /reference/forms/types/options/error_bubbling.rst.inc
62
62
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>`:
37
37
38
38
.. include :: /reference/forms/types/options/disabled.rst.inc
39
39
40
- .. include :: /reference/forms/types/options/empty_data_declaration .rst.inc
40
+ .. include :: /reference/forms/types/options/text_empty_data_declaration .rst.inc
41
41
42
42
The default value is ``'' `` (the empty string).
43
43
44
- .. include :: /reference/forms/types/options/empty_data_description .rst.inc
44
+ .. include :: /reference/forms/types/options/text_empty_data_description .rst.inc
45
45
46
46
.. include :: /reference/forms/types/options/error_bubbling.rst.inc
47
47
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>`:
43
43
44
44
.. include :: /reference/forms/types/options/disabled.rst.inc
45
45
46
- .. include :: /reference/forms/types/options/empty_data_declaration .rst.inc
46
+ .. include :: /reference/forms/types/options/text_empty_data_declaration .rst.inc
47
47
48
48
The default value is ``'' `` (the empty string).
49
49
50
- .. include :: /reference/forms/types/options/empty_data_description .rst.inc
50
+ .. include :: /reference/forms/types/options/text_empty_data_description .rst.inc
51
51
52
52
.. include :: /reference/forms/types/options/error_bubbling.rst.inc
53
53
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>`:
27
27
28
28
.. include :: /reference/forms/types/options/disabled.rst.inc
29
29
30
- .. include :: /reference/forms/types/options/empty_data_declaration .rst.inc
30
+ .. include :: /reference/forms/types/options/text_empty_data_declaration .rst.inc
31
31
32
32
From an HTTP perspective, submitted data is always a string or an array of strings.
33
33
So by default, the form will treat any empty string as null. If you prefer to get
34
34
an empty string, explicitly set the ``empty_data `` option to an empty string.
35
35
36
- .. include :: /reference/forms/types/options/empty_data_description .rst.inc
36
+ .. include :: /reference/forms/types/options/text_empty_data_description .rst.inc
37
37
38
38
.. include :: /reference/forms/types/options/error_bubbling.rst.inc
39
39
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>`:
40
40
41
41
.. include :: /reference/forms/types/options/disabled.rst.inc
42
42
43
- .. include :: /reference/forms/types/options/empty_data_declaration .rst.inc
43
+ .. include :: /reference/forms/types/options/text_empty_data_declaration .rst.inc
44
44
45
45
The default value is ``'' `` (the empty string).
46
46
47
- .. include :: /reference/forms/types/options/empty_data_description .rst.inc
47
+ .. include :: /reference/forms/types/options/text_empty_data_description .rst.inc
48
48
49
49
.. include :: /reference/forms/types/options/error_bubbling.rst.inc
50
50
Original file line number Diff line number Diff line change @@ -50,11 +50,11 @@ These options inherit from the :doc:`FormType </reference/forms/types/form>`:
50
50
51
51
.. include :: /reference/forms/types/options/disabled.rst.inc
52
52
53
- .. include :: /reference/forms/types/options/empty_data_declaration .rst.inc
53
+ .. include :: /reference/forms/types/options/text_empty_data_declaration .rst.inc
54
54
55
55
The default value is ``'' `` (the empty string).
56
56
57
- .. include :: /reference/forms/types/options/empty_data_description .rst.inc
57
+ .. include :: /reference/forms/types/options/text_empty_data_description .rst.inc
58
58
59
59
.. include :: /reference/forms/types/options/error_bubbling.rst.inc
60
60
You can’t perform that action at this time.
0 commit comments