Skip to content

Commit e298929

Browse files
a-menshchikovjaviereguiluz
authored andcommitted
Added support for using the "{{ label }}" placeholder in constraint messages
1 parent f556637 commit e298929

32 files changed

+175
-0
lines changed

components/form.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,11 @@ and the errors will display next to the fields on error.
728728
For a list of all of the built-in validation constraints, see
729729
:doc:`/reference/constraints`.
730730

731+
.. versionadded:: 5.2
732+
733+
Constraint message can contains ``{{ label }}`` placeholder that will be replaced
734+
by corresponding form field label (in view of ``label_format`` option).
735+
731736
Accessing Form Errors
732737
~~~~~~~~~~~~~~~~~~~~~
733738

forms.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,11 @@ corresponding errors printed out with the form. Read the
548548
:doc:`Symfony validation documentation </validation>` to learn more about this
549549
powerful feature.
550550

551+
.. versionadded:: 5.2
552+
553+
Constraint message can contains ``{{ label }}`` placeholder that will be replaced
554+
by corresponding form field label (in view of ``label_format`` option).
555+
551556
Other Common Form Features
552557
--------------------------
553558

reference/constraints/Blank.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ You can use the following parameters in this message:
102102
Parameter Description
103103
=============== ==============================================================
104104
``{{ value }}`` The current (invalid) value
105+
``{{ label }}`` Corresponding form field label
105106
=============== ==============================================================
106107

108+
.. versionadded:: 5.2
109+
110+
The ``{{ label }}`` parameter was introduced in Symfony 5.2.
111+
107112
.. include:: /reference/constraints/_payload-option.rst.inc

reference/constraints/CardScheme.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,13 @@ You can use the following parameters in this message:
112112
Parameter Description
113113
=============== ==============================================================
114114
``{{ value }}`` The current (invalid) value
115+
``{{ label }}`` Corresponding form field label
115116
=============== ==============================================================
116117

118+
.. versionadded:: 5.2
119+
120+
The ``{{ label }}`` parameter was introduced in Symfony 5.2.
121+
117122
.. include:: /reference/constraints/_payload-option.rst.inc
118123

119124
schemes

reference/constraints/Choice.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,11 @@ You can use the following parameters in this message:
392392
Parameter Description
393393
=============== ==============================================================
394394
``{{ value }}`` The current (invalid) value
395+
``{{ label }}`` Corresponding form field label
395396
=============== ==============================================================
396397

398+
.. versionadded:: 5.2
399+
400+
The ``{{ label }}`` parameter was introduced in Symfony 5.2.
401+
397402
.. include:: /reference/constraints/_payload-option.rst.inc

reference/constraints/Currency.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,13 @@ You can use the following parameters in this message:
9494
Parameter Description
9595
=============== ==============================================================
9696
``{{ value }}`` The current (invalid) value
97+
``{{ label }}`` Corresponding form field label
9798
=============== ==============================================================
9899

100+
.. versionadded:: 5.2
101+
102+
The ``{{ label }}`` parameter was introduced in Symfony 5.2.
103+
99104
.. include:: /reference/constraints/_payload-option.rst.inc
100105

101106
.. _`3-letter ISO 4217`: https://en.wikipedia.org/wiki/ISO_4217

reference/constraints/Date.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ You can use the following parameters in this message:
9898
Parameter Description
9999
=============== ==============================================================
100100
``{{ value }}`` The current (invalid) value
101+
``{{ label }}`` Corresponding form field label
101102
=============== ==============================================================
102103

104+
.. versionadded:: 5.2
105+
106+
The ``{{ label }}`` parameter was introduced in Symfony 5.2.
107+
103108
.. include:: /reference/constraints/_payload-option.rst.inc

reference/constraints/DateTime.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ You can use the following parameters in this message:
107107
Parameter Description
108108
=============== ==============================================================
109109
``{{ value }}`` The current (invalid) value
110+
``{{ label }}`` Corresponding form field label
110111
=============== ==============================================================
111112

113+
.. versionadded:: 5.2
114+
115+
The ``{{ label }}`` parameter was introduced in Symfony 5.2.
116+
112117
.. include:: /reference/constraints/_payload-option.rst.inc

reference/constraints/Email.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,13 @@ You can use the following parameters in this message:
101101
Parameter Description
102102
=============== ==============================================================
103103
``{{ value }}`` The current (invalid) value
104+
``{{ label }}`` Corresponding form field label
104105
=============== ==============================================================
105106

107+
.. versionadded:: 5.2
108+
109+
The ``{{ label }}`` parameter was introduced in Symfony 5.2.
110+
106111
mode
107112
~~~~
108113

reference/constraints/Expression.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,13 @@ You can use the following parameters in this message:
260260
Parameter Description
261261
=============== ==============================================================
262262
``{{ value }}`` The current (invalid) value
263+
``{{ label }}`` Corresponding form field label
263264
=============== ==============================================================
264265

266+
.. versionadded:: 5.2
267+
268+
The ``{{ label }}`` parameter was introduced in Symfony 5.2.
269+
265270
.. include:: /reference/constraints/_payload-option.rst.inc
266271

267272
values

0 commit comments

Comments
 (0)