Skip to content

Commit 8af6094

Browse files
committed
Added support for using the "{{ label }}" placeholder in constraint messages
1 parent f556637 commit 8af6094

32 files changed

+43
-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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ 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

107108
.. include:: /reference/constraints/_payload-option.rst.inc

reference/constraints/CardScheme.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ 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

117118
.. include:: /reference/constraints/_payload-option.rst.inc

reference/constraints/Choice.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ 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

397398
.. include:: /reference/constraints/_payload-option.rst.inc

reference/constraints/Currency.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ 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

99100
.. include:: /reference/constraints/_payload-option.rst.inc

reference/constraints/Date.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ 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

103104
.. include:: /reference/constraints/_payload-option.rst.inc

reference/constraints/DateTime.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ 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

112113
.. include:: /reference/constraints/_payload-option.rst.inc

reference/constraints/Email.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ 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

106107
mode

reference/constraints/Expression.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ 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

265266
.. include:: /reference/constraints/_payload-option.rst.inc

reference/constraints/Hostname.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ You can use the following parameters in this message:
110110
Parameter Description
111111
=============== ==============================================================
112112
``{{ value }}`` The current (invalid) value
113+
``{{ label }}`` Corresponding form field label
113114
=============== ==============================================================
114115

115116
.. include:: /reference/constraints/_payload-option.rst.inc

reference/constraints/Iban.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ You can use the following parameters in this message:
108108
Parameter Description
109109
=============== ==============================================================
110110
``{{ value }}`` The current (invalid) value
111+
``{{ label }}`` Corresponding form field label
111112
=============== ==============================================================
112113

113114
.. include:: /reference/constraints/_payload-option.rst.inc

reference/constraints/Ip.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ You can use the following parameters in this message:
9595
Parameter Description
9696
=============== ==============================================================
9797
``{{ value }}`` The current (invalid) value
98+
``{{ label }}`` Corresponding form field label
9899
=============== ==============================================================
99100

100101
.. include:: /reference/constraints/_normalizer-option.rst.inc

reference/constraints/IsFalse.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ You can use the following parameters in this message:
125125
Parameter Description
126126
=============== ==============================================================
127127
``{{ value }}`` The current (invalid) value
128+
``{{ label }}`` Corresponding form field label
128129
=============== ==============================================================
129130

130131
.. include:: /reference/constraints/_payload-option.rst.inc

reference/constraints/IsNull.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ You can use the following parameters in this message:
9696
Parameter Description
9797
=============== ==============================================================
9898
``{{ value }}`` The current (invalid) value
99+
``{{ label }}`` Corresponding form field label
99100
=============== ==============================================================
100101

101102
.. include:: /reference/constraints/_payload-option.rst.inc

reference/constraints/IsTrue.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ You can use the following parameters in this message:
129129
Parameter Description
130130
=============== ==============================================================
131131
``{{ value }}`` The current (invalid) value
132+
``{{ label }}`` Corresponding form field label
132133
=============== ==============================================================
133134

134135
.. include:: /reference/constraints/_payload-option.rst.inc

reference/constraints/Isbn.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ You can use the following parameters in this message:
109109
Parameter Description
110110
=============== ==============================================================
111111
``{{ value }}`` The current (invalid) value
112+
``{{ label }}`` Corresponding form field label
112113
=============== ==============================================================
113114

114115
.. include:: /reference/constraints/_groups-option.rst.inc
@@ -127,6 +128,7 @@ You can use the following parameters in this message:
127128
Parameter Description
128129
=============== ==============================================================
129130
``{{ value }}`` The current (invalid) value
131+
``{{ label }}`` Corresponding form field label
130132
=============== ==============================================================
131133

132134
isbn13Message
@@ -143,6 +145,7 @@ You can use the following parameters in this message:
143145
Parameter Description
144146
=============== ==============================================================
145147
``{{ value }}`` The current (invalid) value
148+
``{{ label }}`` Corresponding form field label
146149
=============== ==============================================================
147150

148151
message
@@ -159,6 +162,7 @@ You can use the following parameters in this message:
159162
Parameter Description
160163
=============== ==============================================================
161164
``{{ value }}`` The current (invalid) value
165+
``{{ label }}`` Corresponding form field label
162166
=============== ==============================================================
163167

164168
.. include:: /reference/constraints/_payload-option.rst.inc

reference/constraints/Isin.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ You can use the following parameters in this message:
9292
Parameter Description
9393
=============== ==============================================================
9494
``{{ value }}`` The current (invalid) value
95+
``{{ label }}`` Corresponding form field label
9596
=============== ==============================================================
9697

9798
.. include:: /reference/constraints/_payload-option.rst.inc

reference/constraints/Issn.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ 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

107108
.. include:: /reference/constraints/_payload-option.rst.inc

reference/constraints/Language.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ You can use the following parameters in this message:
106106
Parameter Description
107107
=============== ==============================================================
108108
``{{ value }}`` The current (invalid) value
109+
``{{ label }}`` Corresponding form field label
109110
=============== ==============================================================
110111

111112
.. include:: /reference/constraints/_payload-option.rst.inc

reference/constraints/Locale.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ 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

112113
.. include:: /reference/constraints/_payload-option.rst.inc

reference/constraints/Luhn.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ 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

106107
.. include:: /reference/constraints/_payload-option.rst.inc

reference/constraints/NotBlank.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ You can use the following parameters in this message:
105105
Parameter Description
106106
=============== ==============================================================
107107
``{{ value }}`` The current (invalid) value
108+
``{{ label }}`` Corresponding form field label
108109
=============== ==============================================================
109110

110111
.. include:: /reference/constraints/_normalizer-option.rst.inc

reference/constraints/NotNull.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ 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

99100
.. include:: /reference/constraints/_payload-option.rst.inc

reference/constraints/Range.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ You can use the following parameters in this message:
330330
Parameter Description
331331
=============== ==============================================================
332332
``{{ value }}`` The current (invalid) value
333+
``{{ label }}`` Corresponding form field label
333334
=============== ==============================================================
334335

335336
max

reference/constraints/Regex.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ You can use the following parameters in this message:
275275
Parameter Description
276276
=============== ==============================================================
277277
``{{ value }}`` The current (invalid) value
278+
``{{ label }}`` Corresponding form field label
278279
=============== ==============================================================
279280

280281
pattern

reference/constraints/Time.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ 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

106107
.. include:: /reference/constraints/_payload-option.rst.inc

reference/constraints/Timezone.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ You can use the following parameters in this message:
123123
Parameter Description
124124
=============== ==============================================================
125125
``{{ value }}`` The current (invalid) value
126+
``{{ label }}`` Corresponding form field label
126127
=============== ==============================================================
127128

128129
.. include:: /reference/constraints/_payload-option.rst.inc

reference/constraints/Type.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ Parameter Description
162162
=============== ==============================================================
163163
``{{ type }}`` The expected type
164164
``{{ value }}`` The current (invalid) value
165+
``{{ label }}`` Corresponding form field label
165166
=============== ==============================================================
166167

167168
.. include:: /reference/constraints/_payload-option.rst.inc

reference/constraints/UniqueEntity.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ You can use the following parameters in this message:
291291
Parameter Description
292292
=============== ==============================================================
293293
``{{ value }}`` The current (invalid) value
294+
``{{ label }}`` Corresponding form field label
294295
=============== ==============================================================
295296

296297
.. include:: /reference/constraints/_payload-option.rst.inc

reference/constraints/Url.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ 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

103104
.. configuration-block::

reference/constraints/Uuid.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ You can use the following parameters in this message:
9797
Parameter Description
9898
=============== ==============================================================
9999
``{{ value }}`` The current (invalid) value
100+
``{{ label }}`` Corresponding form field label
100101
=============== ==============================================================
101102

102103
.. include:: /reference/constraints/_normalizer-option.rst.inc

0 commit comments

Comments
 (0)