From ef0ea78ab48c5567e59f2b1c992d24f0d1179cae Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 30 Aug 2016 11:17:10 +0200 Subject: [PATCH 1/4] Explain the limitations of the custom messages in UniqueEntity --- reference/constraints/UniqueEntity.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/reference/constraints/UniqueEntity.rst b/reference/constraints/UniqueEntity.rst index 211fb0a3753..fd484191480 100644 --- a/reference/constraints/UniqueEntity.rst +++ b/reference/constraints/UniqueEntity.rst @@ -132,7 +132,11 @@ message **type**: ``string`` **default**: ``This value is already used.`` -The message that's displayed when this constraint fails. +The message that's displayed when this constraint fails. When using multiple +fields, the ``{{ vallue }}`` parameter only contains the value of the first +wrong field. Therefore, you cannot define a custom message that displays all +the wrong values (e.g. the following won't work: +``This {{ name }} name and {{ email }} email combination is in use. Change either of them``) em ~~ From 4bd081e3970395c30cab2a98548ba0a9b5d71f68 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 30 Aug 2016 11:38:39 +0200 Subject: [PATCH 2/4] Reworded everything --- reference/constraints/UniqueEntity.rst | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/reference/constraints/UniqueEntity.rst b/reference/constraints/UniqueEntity.rst index fd484191480..fceded5bfa6 100644 --- a/reference/constraints/UniqueEntity.rst +++ b/reference/constraints/UniqueEntity.rst @@ -132,11 +132,14 @@ message **type**: ``string`` **default**: ``This value is already used.`` -The message that's displayed when this constraint fails. When using multiple -fields, the ``{{ vallue }}`` parameter only contains the value of the first -wrong field. Therefore, you cannot define a custom message that displays all -the wrong values (e.g. the following won't work: -``This {{ name }} name and {{ email }} email combination is in use. Change either of them``) +The message that's displayed when this constraint fails. This message is always +mapped to the first field causing the violation, even when using multiple fields +in the constraint. + +When using a custom message, you can include the ``{{ value }}`` placeholder to +display a string representation of the invalid entity. If the entity doesn't +define the ``__toString()`` method, the following generic value will be used: +*"Object of class __CLASS__ identified by "* em ~~ From 1f91326ed584e9404c3c0cc52998006380d16c9d Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 31 Aug 2016 17:04:13 +0200 Subject: [PATCH 3/4] Minor reword to be more concise --- reference/constraints/UniqueEntity.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/reference/constraints/UniqueEntity.rst b/reference/constraints/UniqueEntity.rst index fceded5bfa6..6cb48c2d119 100644 --- a/reference/constraints/UniqueEntity.rst +++ b/reference/constraints/UniqueEntity.rst @@ -136,10 +136,10 @@ The message that's displayed when this constraint fails. This message is always mapped to the first field causing the violation, even when using multiple fields in the constraint. -When using a custom message, you can include the ``{{ value }}`` placeholder to -display a string representation of the invalid entity. If the entity doesn't -define the ``__toString()`` method, the following generic value will be used: -*"Object of class __CLASS__ identified by "* +Messages can include the ``{{ value }}`` placeholder to display a string +representation of the invalid entity. If the entity doesn't define the +``__toString()`` method, the following generic value will be used: *"Object of +class __CLASS__ identified by "* em ~~ From a903b010df4327f7841217d0693cab2453595fc8 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 4 Oct 2016 13:20:58 +0200 Subject: [PATCH 4/4] Added the versionadded directive --- reference/constraints/UniqueEntity.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/reference/constraints/UniqueEntity.rst b/reference/constraints/UniqueEntity.rst index 6cb48c2d119..7d03f107aa9 100644 --- a/reference/constraints/UniqueEntity.rst +++ b/reference/constraints/UniqueEntity.rst @@ -136,6 +136,10 @@ The message that's displayed when this constraint fails. This message is always mapped to the first field causing the violation, even when using multiple fields in the constraint. +.. versionadded:: 3.1 + The ability to include the invalid value into the message was introduced + in Symfony 3.1. + Messages can include the ``{{ value }}`` placeholder to display a string representation of the invalid entity. If the entity doesn't define the ``__toString()`` method, the following generic value will be used: *"Object of