Skip to content

Commit 4c10ea8

Browse files
javiereguiluzwouterj
authored andcommitted
Explain the limitations of the custom messages in UniqueEntity
1 parent 36a460d commit 4c10ea8

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

reference/constraints/UniqueEntity.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,18 @@ message
132132

133133
**type**: ``string`` **default**: ``This value is already used.``
134134

135-
The message that's displayed when this constraint fails.
135+
The message that's displayed when this constraint fails. This message is always
136+
mapped to the first field causing the violation, even when using multiple fields
137+
in the constraint.
138+
139+
.. versionadded:: 3.1
140+
The ability to include the invalid value into the message was introduced
141+
in Symfony 3.1.
142+
143+
Messages can include the ``{{ value }}`` placeholder to display a string
144+
representation of the invalid entity. If the entity doesn't define the
145+
``__toString()`` method, the following generic value will be used: *"Object of
146+
class __CLASS__ identified by <comma separated IDs>"*
136147

137148
em
138149
~~

0 commit comments

Comments
 (0)