Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b6f42ee

Browse files
peter-gribanovPeter Gribanov
authored and
Peter Gribanov
committedSep 27, 2022
string is the preferred value type for TextType
1 parent 18967c7 commit b6f42ee

11 files changed

+47
-18
lines changed
 

‎reference/forms/types/color.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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

6161
The 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

‎reference/forms/types/email.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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

4242
The 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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
``empty_data``
2+
~~~~~~~~~~~~~~
3+
4+
**type**: ``mixed``
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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.

‎reference/forms/types/password.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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

6464
The 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

‎reference/forms/types/range.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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

5757
The 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

‎reference/forms/types/search.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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

4242
The 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

‎reference/forms/types/tel.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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

4848
The 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

‎reference/forms/types/text.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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

3232
From an HTTP perspective, submitted data is always a string or an array of strings.
3333
So by default, the form will treat any empty string as null. If you prefer to get
3434
an 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

‎reference/forms/types/textarea.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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

4545
The 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

‎reference/forms/types/url.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ 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_declaration.rst.inc
53+
.. include:: /reference/forms/types/options/text_empty_data_declaration.rst.inc
5454

5555
The default value is ``''`` (the empty string).
5656

57-
.. include:: /reference/forms/types/options/empty_data_description.rst.inc
57+
.. include:: /reference/forms/types/options/text_empty_data_description.rst.inc
5858

5959
.. include:: /reference/forms/types/options/error_bubbling.rst.inc
6060

0 commit comments

Comments
 (0)
Please sign in to comment.