Skip to content

Commit 685ce0f

Browse files
committed
Merge branch '5.2' into 5.x
* 5.2: [Form] Documented legacy_error_messages
2 parents ac6dd47 + 0ccfa6e commit 685ce0f

31 files changed

+1267
-1019
lines changed

forms.rst

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,47 @@ To see the second approach - adding constraints to the form - and to
553553
learn more about the validation constraints, please refer to the
554554
:doc:`Symfony validation documentation </validation>`.
555555

556+
.. versionadded:: 5.2
557+
558+
In Symfony 5.2, the form validation messages have been rewritten to be more
559+
user-friendly. Set the ``legacy_error_messages`` option to ``false`` to
560+
enable these new messages:
561+
562+
.. configuration-block::
563+
564+
.. code-block:: yaml
565+
566+
# config/packages/framework.yaml
567+
framework:
568+
form:
569+
legacy_error_messages: false
570+
571+
.. code-block:: xml
572+
573+
<!-- config/packages/framework.xml -->
574+
<?xml version="1.0" encoding="UTF-8" ?>
575+
<container xmlns="http://symfony.com/schema/dic/services"
576+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
577+
xmlns:framework="http://symfony.com/schema/dic/symfony"
578+
xsi:schemaLocation="http://symfony.com/schema/dic/services
579+
https://symfony.com/schema/dic/services/services-1.0.xsd
580+
http://symfony.com/schema/dic/symfony
581+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
582+
583+
<framework:config>
584+
<framework:form legacy-error-messages="false"/>
585+
</framework:config>
586+
</container>
587+
588+
.. code-block:: php
589+
590+
// config/packages/framework.php
591+
$container->loadFromExtension('framework', [
592+
'form' => [
593+
'legacy-error-messages' => false,
594+
],
595+
]);
596+
556597
Other Common Form Features
557598
--------------------------
558599

reference/forms/types/birthday.rst

Lines changed: 45 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -14,51 +14,57 @@ This type is essentially the same as the :doc:`DateType </reference/forms/types/
1414
type, but with a more appropriate default for the `years`_ option. The `years`_
1515
option defaults to 120 years ago to the current year.
1616

17-
+----------------------+-------------------------------------------------------------------------------+
18-
| Underlying Data Type | can be ``DateTime``, ``string``, ``timestamp``, or ``array`` |
19-
| | (see the :ref:`input option <form-reference-date-input>`) |
20-
+----------------------+-------------------------------------------------------------------------------+
21-
| Rendered as | can be three select boxes or 1 or 3 text boxes, based on the `widget`_ option |
22-
+----------------------+-------------------------------------------------------------------------------+
23-
| Overridden options | - `years`_ |
24-
+----------------------+-------------------------------------------------------------------------------+
25-
| Inherited options | from the :doc:`DateType </reference/forms/types/date>`: |
26-
| | |
27-
| | - `choice_translation_domain`_ |
28-
| | - `days`_ |
29-
| | - `placeholder`_ |
30-
| | - `format`_ |
31-
| | - `input`_ |
32-
| | - `input_format`_ |
33-
| | - `model_timezone`_ |
34-
| | - `months`_ |
35-
| | - `view_timezone`_ |
36-
| | - `widget`_ |
37-
| | |
38-
| | from the :doc:`FormType </reference/forms/types/form>`: |
39-
| | |
40-
| | - `attr`_ |
41-
| | - `data`_ |
42-
| | - `disabled`_ |
43-
| | - `help`_ |
44-
| | - `help_attr`_ |
45-
| | - `help_html`_ |
46-
| | - `inherit_data`_ |
47-
| | - `invalid_message`_ |
48-
| | - `invalid_message_parameters`_ |
49-
| | - `mapped`_ |
50-
| | - `row_attr`_ |
51-
+----------------------+-------------------------------------------------------------------------------+
52-
| Parent type | :doc:`DateType </reference/forms/types/date>` |
53-
+----------------------+-------------------------------------------------------------------------------+
54-
| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\BirthdayType` |
55-
+----------------------+-------------------------------------------------------------------------------+
17+
+---------------------------+-------------------------------------------------------------------------------+
18+
| Underlying Data Type | can be ``DateTime``, ``string``, ``timestamp``, or ``array`` |
19+
| | (see the :ref:`input option <form-reference-date-input>`) |
20+
+---------------------------+-------------------------------------------------------------------------------+
21+
| Rendered as | can be three select boxes or 1 or 3 text boxes, based on the `widget`_ option |
22+
+---------------------------+-------------------------------------------------------------------------------+
23+
| Overridden options | - `invalid_message`_ |
24+
| | - `years`_ |
25+
+---------------------------+-------------------------------------------------------------------------------+
26+
| Inherited options | from the :doc:`DateType </reference/forms/types/date>`: |
27+
| | |
28+
| | - `choice_translation_domain`_ |
29+
| | - `days`_ |
30+
| | - `placeholder`_ |
31+
| | - `format`_ |
32+
| | - `input`_ |
33+
| | - `input_format`_ |
34+
| | - `model_timezone`_ |
35+
| | - `months`_ |
36+
| | - `view_timezone`_ |
37+
| | - `widget`_ |
38+
| | |
39+
| | from the :doc:`FormType </reference/forms/types/form>`: |
40+
| | |
41+
| | - `attr`_ |
42+
| | - `data`_ |
43+
| | - `disabled`_ |
44+
| | - `help`_ |
45+
| | - `help_attr`_ |
46+
| | - `help_html`_ |
47+
| | - `inherit_data`_ |
48+
| | - `invalid_message_parameters`_ |
49+
| | - `mapped`_ |
50+
| | - `row_attr`_ |
51+
+---------------------------+-------------------------------------------------------------------------------+
52+
| Default invalid message | Please enter a valid birthdate. |
53+
+---------------------------+-------------------------------------------------------------------------------+
54+
| Legacy invalid message | The value {{ value }} is not valid. |
55+
+---------------------------+-------------------------------------------------------------------------------+
56+
| Parent type | :doc:`DateType </reference/forms/types/date>` |
57+
+---------------------------+-------------------------------------------------------------------------------+
58+
| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\BirthdayType` |
59+
+---------------------------+-------------------------------------------------------------------------------+
5660

5761
.. include:: /reference/forms/types/options/_debug_form.rst.inc
5862

5963
Overridden Options
6064
------------------
6165

66+
.. include:: /reference/forms/types/options/invalid_message.rst.inc
67+
6268
``years``
6369
~~~~~~~~~
6470

@@ -128,8 +134,6 @@ These options inherit from the :doc:`FormType </reference/forms/types/form>`:
128134

129135
.. include:: /reference/forms/types/options/inherit_data.rst.inc
130136

131-
.. include:: /reference/forms/types/options/invalid_message.rst.inc
132-
133137
.. include:: /reference/forms/types/options/invalid_message_parameters.rst.inc
134138

135139
.. include:: /reference/forms/types/options/mapped.rst.inc

reference/forms/types/checkbox.rst

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,39 @@ you can specify an array of values that, if submitted, will be evaluated
1111
to "false" as well (this differs from what HTTP defines, but can be handy
1212
if you want to handle submitted values like "0" or "false").
1313

14-
+-------------+------------------------------------------------------------------------+
15-
| Rendered as | ``input`` ``checkbox`` field |
16-
+-------------+------------------------------------------------------------------------+
17-
| Options | - `false_values`_ |
18-
| | - `value`_ |
19-
+-------------+------------------------------------------------------------------------+
20-
| Overridden | - `compound`_ |
21-
| options | - `empty_data`_ |
22-
+-------------+------------------------------------------------------------------------+
23-
| Inherited | - `attr`_ |
24-
| options | - `data`_ |
25-
| | - `disabled`_ |
26-
| | - `error_bubbling`_ |
27-
| | - `error_mapping`_ |
28-
| | - `help`_ |
29-
| | - `help_attr`_ |
30-
| | - `help_html`_ |
31-
| | - `label`_ |
32-
| | - `label_attr`_ |
33-
| | - `label_format`_ |
34-
| | - `mapped`_ |
35-
| | - `required`_ |
36-
| | - `row_attr`_ |
37-
+-------------+------------------------------------------------------------------------+
38-
| Parent type | :doc:`FormType </reference/forms/types/form>` |
39-
+-------------+------------------------------------------------------------------------+
40-
| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\CheckboxType` |
41-
+-------------+------------------------------------------------------------------------+
14+
+---------------------------+------------------------------------------------------------------------+
15+
| Rendered as | ``input`` ``checkbox`` field |
16+
+---------------------------+------------------------------------------------------------------------+
17+
| Options | - `false_values`_ |
18+
| | - `value`_ |
19+
+---------------------------+------------------------------------------------------------------------+
20+
| Overridden options | - `compound`_ |
21+
| | - `empty_data`_ |
22+
| | - `invalid_message`_ |
23+
+---------------------------+------------------------------------------------------------------------+
24+
| Inherited options | - `attr`_ |
25+
| | - `data`_ |
26+
| | - `disabled`_ |
27+
| | - `error_bubbling`_ |
28+
| | - `error_mapping`_ |
29+
| | - `help`_ |
30+
| | - `help_attr`_ |
31+
| | - `help_html`_ |
32+
| | - `label`_ |
33+
| | - `label_attr`_ |
34+
| | - `label_format`_ |
35+
| | - `mapped`_ |
36+
| | - `required`_ |
37+
| | - `row_attr`_ |
38+
+---------------------------+------------------------------------------------------------------------+
39+
| Default invalid message | The checkbox has an invalid value. |
40+
+---------------------------+------------------------------------------------------------------------+
41+
| Legacy invalid message | The value {{ value }} is not valid. |
42+
+---------------------------+------------------------------------------------------------------------+
43+
| Parent type | :doc:`FormType </reference/forms/types/form>` |
44+
+---------------------------+------------------------------------------------------------------------+
45+
| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\CheckboxType` |
46+
+---------------------------+------------------------------------------------------------------------+
4247

4348
.. include:: /reference/forms/types/options/_debug_form.rst.inc
4449

@@ -74,6 +79,8 @@ Overridden Options
7479

7580
.. include:: /reference/forms/types/options/checkbox_empty_data.rst.inc
7681

82+
.. include:: /reference/forms/types/options/invalid_message.rst.inc
83+
7784
Inherited Options
7885
-----------------
7986

0 commit comments

Comments
 (0)