Skip to content

Added support for using the "{{ label }}" placeholder in constraint messages #14161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions components/form.rst
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,11 @@ and the errors will display next to the fields on error.
For a list of all of the built-in validation constraints, see
:doc:`/reference/constraints`.

.. versionadded:: 5.2

Constraint message can contains ``{{ label }}`` placeholder that will be replaced
by corresponding form field label (in view of ``label_format`` option).

Accessing Form Errors
~~~~~~~~~~~~~~~~~~~~~

Expand Down
5 changes: 5 additions & 0 deletions forms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,11 @@ corresponding errors printed out with the form. Read the
:doc:`Symfony validation documentation </validation>` to learn more about this
powerful feature.

.. versionadded:: 5.2

Constraint message can contains ``{{ label }}`` placeholder that will be replaced
by corresponding form field label (in view of ``label_format`` option).

Other Common Form Features
--------------------------

Expand Down
5 changes: 5 additions & 0 deletions reference/constraints/Blank.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ You can use the following parameters in this message:
Parameter Description
=============== ==============================================================
``{{ value }}`` The current (invalid) value
``{{ label }}`` Corresponding form field label
=============== ==============================================================

.. versionadded:: 5.2

The ``{{ label }}`` parameter was introduced in Symfony 5.2.

.. include:: /reference/constraints/_payload-option.rst.inc
5 changes: 5 additions & 0 deletions reference/constraints/CardScheme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,13 @@ You can use the following parameters in this message:
Parameter Description
=============== ==============================================================
``{{ value }}`` The current (invalid) value
``{{ label }}`` Corresponding form field label
=============== ==============================================================

.. versionadded:: 5.2

The ``{{ label }}`` parameter was introduced in Symfony 5.2.

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

schemes
Expand Down
5 changes: 5 additions & 0 deletions reference/constraints/Choice.rst
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,11 @@ You can use the following parameters in this message:
Parameter Description
=============== ==============================================================
``{{ value }}`` The current (invalid) value
``{{ label }}`` Corresponding form field label
=============== ==============================================================

.. versionadded:: 5.2

The ``{{ label }}`` parameter was introduced in Symfony 5.2.

.. include:: /reference/constraints/_payload-option.rst.inc
5 changes: 5 additions & 0 deletions reference/constraints/Currency.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,13 @@ You can use the following parameters in this message:
Parameter Description
=============== ==============================================================
``{{ value }}`` The current (invalid) value
``{{ label }}`` Corresponding form field label
=============== ==============================================================

.. versionadded:: 5.2

The ``{{ label }}`` parameter was introduced in Symfony 5.2.

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

.. _`3-letter ISO 4217`: https://en.wikipedia.org/wiki/ISO_4217
5 changes: 5 additions & 0 deletions reference/constraints/Date.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ You can use the following parameters in this message:
Parameter Description
=============== ==============================================================
``{{ value }}`` The current (invalid) value
``{{ label }}`` Corresponding form field label
=============== ==============================================================

.. versionadded:: 5.2

The ``{{ label }}`` parameter was introduced in Symfony 5.2.

.. include:: /reference/constraints/_payload-option.rst.inc
5 changes: 5 additions & 0 deletions reference/constraints/DateTime.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ You can use the following parameters in this message:
Parameter Description
=============== ==============================================================
``{{ value }}`` The current (invalid) value
``{{ label }}`` Corresponding form field label
=============== ==============================================================

.. versionadded:: 5.2

The ``{{ label }}`` parameter was introduced in Symfony 5.2.

.. include:: /reference/constraints/_payload-option.rst.inc
5 changes: 5 additions & 0 deletions reference/constraints/Email.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,13 @@ You can use the following parameters in this message:
Parameter Description
=============== ==============================================================
``{{ value }}`` The current (invalid) value
``{{ label }}`` Corresponding form field label
=============== ==============================================================

.. versionadded:: 5.2

The ``{{ label }}`` parameter was introduced in Symfony 5.2.

mode
~~~~

Expand Down
5 changes: 5 additions & 0 deletions reference/constraints/Expression.rst
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,13 @@ You can use the following parameters in this message:
Parameter Description
=============== ==============================================================
``{{ value }}`` The current (invalid) value
``{{ label }}`` Corresponding form field label
=============== ==============================================================

.. versionadded:: 5.2

The ``{{ label }}`` parameter was introduced in Symfony 5.2.

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

values
Expand Down
5 changes: 5 additions & 0 deletions reference/constraints/Hostname.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,13 @@ You can use the following parameters in this message:
Parameter Description
=============== ==============================================================
``{{ value }}`` The current (invalid) value
``{{ label }}`` Corresponding form field label
=============== ==============================================================

.. versionadded:: 5.2

The ``{{ label }}`` parameter was introduced in Symfony 5.2.

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

``requireTld``
Expand Down
5 changes: 5 additions & 0 deletions reference/constraints/Iban.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,13 @@ You can use the following parameters in this message:
Parameter Description
=============== ==============================================================
``{{ value }}`` The current (invalid) value
``{{ label }}`` Corresponding form field label
=============== ==============================================================

.. versionadded:: 5.2

The ``{{ label }}`` parameter was introduced in Symfony 5.2.

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

.. _`International Bank Account Number (IBAN)`: https://en.wikipedia.org/wiki/International_Bank_Account_Number
5 changes: 5 additions & 0 deletions reference/constraints/Ip.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,13 @@ You can use the following parameters in this message:
Parameter Description
=============== ==============================================================
``{{ value }}`` The current (invalid) value
``{{ label }}`` Corresponding form field label
=============== ==============================================================

.. versionadded:: 5.2

The ``{{ label }}`` parameter was introduced in Symfony 5.2.

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

.. include:: /reference/constraints/_payload-option.rst.inc
Expand Down
5 changes: 5 additions & 0 deletions reference/constraints/IsFalse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ You can use the following parameters in this message:
Parameter Description
=============== ==============================================================
``{{ value }}`` The current (invalid) value
``{{ label }}`` Corresponding form field label
=============== ==============================================================

.. versionadded:: 5.2

The ``{{ label }}`` parameter was introduced in Symfony 5.2.

.. include:: /reference/constraints/_payload-option.rst.inc
5 changes: 5 additions & 0 deletions reference/constraints/IsNull.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ You can use the following parameters in this message:
Parameter Description
=============== ==============================================================
``{{ value }}`` The current (invalid) value
``{{ label }}`` Corresponding form field label
=============== ==============================================================

.. versionadded:: 5.2

The ``{{ label }}`` parameter was introduced in Symfony 5.2.

.. include:: /reference/constraints/_payload-option.rst.inc
5 changes: 5 additions & 0 deletions reference/constraints/IsTrue.rst
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ You can use the following parameters in this message:
Parameter Description
=============== ==============================================================
``{{ value }}`` The current (invalid) value
``{{ label }}`` Corresponding form field label
=============== ==============================================================

.. versionadded:: 5.2

The ``{{ label }}`` parameter was introduced in Symfony 5.2.

.. include:: /reference/constraints/_payload-option.rst.inc
20 changes: 20 additions & 0 deletions reference/constraints/Isbn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,13 @@ You can use the following parameters in this message:
Parameter Description
=============== ==============================================================
``{{ value }}`` The current (invalid) value
``{{ label }}`` Corresponding form field label
=============== ==============================================================

.. versionadded:: 5.2

The ``{{ label }}`` parameter was introduced in Symfony 5.2.

.. include:: /reference/constraints/_groups-option.rst.inc

isbn10Message
Expand All @@ -127,8 +132,13 @@ You can use the following parameters in this message:
Parameter Description
=============== ==============================================================
``{{ value }}`` The current (invalid) value
``{{ label }}`` Corresponding form field label
=============== ==============================================================

.. versionadded:: 5.2

The ``{{ label }}`` parameter was introduced in Symfony 5.2.

isbn13Message
~~~~~~~~~~~~~

Expand All @@ -143,8 +153,13 @@ You can use the following parameters in this message:
Parameter Description
=============== ==============================================================
``{{ value }}`` The current (invalid) value
``{{ label }}`` Corresponding form field label
=============== ==============================================================

.. versionadded:: 5.2

The ``{{ label }}`` parameter was introduced in Symfony 5.2.

message
~~~~~~~

Expand All @@ -159,8 +174,13 @@ You can use the following parameters in this message:
Parameter Description
=============== ==============================================================
``{{ value }}`` The current (invalid) value
``{{ label }}`` Corresponding form field label
=============== ==============================================================

.. versionadded:: 5.2

The ``{{ label }}`` parameter was introduced in Symfony 5.2.

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

type
Expand Down
5 changes: 5 additions & 0 deletions reference/constraints/Isin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,13 @@ You can use the following parameters in this message:
Parameter Description
=============== ==============================================================
``{{ value }}`` The current (invalid) value
``{{ label }}`` Corresponding form field label
=============== ==============================================================

.. versionadded:: 5.2

The ``{{ label }}`` parameter was introduced in Symfony 5.2.

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

.. _`International Securities Identification Number (ISIN)`: https://en.wikipedia.org/wiki/International_Securities_Identification_Number
5 changes: 5 additions & 0 deletions reference/constraints/Issn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,13 @@ You can use the following parameters in this message:
Parameter Description
=============== ==============================================================
``{{ value }}`` The current (invalid) value
``{{ label }}`` Corresponding form field label
=============== ==============================================================

.. versionadded:: 5.2

The ``{{ label }}`` parameter was introduced in Symfony 5.2.

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

requireHyphen
Expand Down
5 changes: 5 additions & 0 deletions reference/constraints/Language.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,13 @@ You can use the following parameters in this message:
Parameter Description
=============== ==============================================================
``{{ value }}`` The current (invalid) value
``{{ label }}`` Corresponding form field label
=============== ==============================================================

.. versionadded:: 5.2

The ``{{ label }}`` parameter was introduced in Symfony 5.2.

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

.. _`ISO 639-1`: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
Expand Down
5 changes: 5 additions & 0 deletions reference/constraints/Locale.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,13 @@ You can use the following parameters in this message:
Parameter Description
=============== ==============================================================
``{{ value }}`` The current (invalid) value
``{{ label }}`` Corresponding form field label
=============== ==============================================================

.. versionadded:: 5.2

The ``{{ label }}`` parameter was introduced in Symfony 5.2.

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

.. _`ICU format locale IDs`: http://userguide.icu-project.org/locale
Expand Down
5 changes: 5 additions & 0 deletions reference/constraints/Luhn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,13 @@ You can use the following parameters in this message:
Parameter Description
=============== ==============================================================
``{{ value }}`` The current (invalid) value
``{{ label }}`` Corresponding form field label
=============== ==============================================================

.. versionadded:: 5.2

The ``{{ label }}`` parameter was introduced in Symfony 5.2.

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

.. _`Luhn algorithm`: https://en.wikipedia.org/wiki/Luhn_algorithm
5 changes: 5 additions & 0 deletions reference/constraints/NotBlank.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,13 @@ You can use the following parameters in this message:
Parameter Description
=============== ==============================================================
``{{ value }}`` The current (invalid) value
``{{ label }}`` Corresponding form field label
=============== ==============================================================

.. versionadded:: 5.2

The ``{{ label }}`` parameter was introduced in Symfony 5.2.

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

.. include:: /reference/constraints/_payload-option.rst.inc
5 changes: 5 additions & 0 deletions reference/constraints/NotNull.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ You can use the following parameters in this message:
Parameter Description
=============== ==============================================================
``{{ value }}`` The current (invalid) value
``{{ label }}`` Corresponding form field label
=============== ==============================================================

.. versionadded:: 5.2

The ``{{ label }}`` parameter was introduced in Symfony 5.2.

.. include:: /reference/constraints/_payload-option.rst.inc
5 changes: 5 additions & 0 deletions reference/constraints/Range.rst
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,13 @@ You can use the following parameters in this message:
Parameter Description
=============== ==============================================================
``{{ value }}`` The current (invalid) value
``{{ label }}`` Corresponding form field label
=============== ==============================================================

.. versionadded:: 5.2

The ``{{ label }}`` parameter was introduced in Symfony 5.2.

max
~~~

Expand Down
5 changes: 5 additions & 0 deletions reference/constraints/Regex.rst
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,13 @@ You can use the following parameters in this message:
Parameter Description
=============== ==============================================================
``{{ value }}`` The current (invalid) value
``{{ label }}`` Corresponding form field label
=============== ==============================================================

.. versionadded:: 5.2

The ``{{ label }}`` parameter was introduced in Symfony 5.2.

pattern
~~~~~~~

Expand Down
5 changes: 5 additions & 0 deletions reference/constraints/Time.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ You can use the following parameters in this message:
Parameter Description
=============== ==============================================================
``{{ value }}`` The current (invalid) value
``{{ label }}`` Corresponding form field label
=============== ==============================================================

.. versionadded:: 5.2

The ``{{ label }}`` parameter was introduced in Symfony 5.2.

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