Skip to content
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

UniqueEntity message can't include the value #6929

Closed
javiereguiluz opened this issue Aug 29, 2016 · 3 comments
Closed

UniqueEntity message can't include the value #6929

javiereguiluz opened this issue Aug 29, 2016 · 3 comments
Labels
hasPR A Pull Request has already been submitted for this issue. Validator

Comments

@javiereguiluz
Copy link
Member

javiereguiluz commented Aug 29, 2016

Constraint messages can include {{ value }} in the message option to display the wrong value introduced by the user. Apparently, you can't do the same in the UniqueEntity constraint, so it should be documented here: http://symfony.com/doc/current/reference/constraints/UniqueEntity.html#message

@HeahDude
Copy link
Contributor

HeahDude commented Aug 29, 2016

Yes, it's been introduced in 2.8 (ref symfony/symfony#15279).

@javiereguiluz
Copy link
Member Author

I'm getting reports (via email) from people who can't make this work. By the way, what's the {{ value }} when the UniqueEntity is matched against several values?

@HeahDude
Copy link
Contributor

The value always represents the validated value (ref https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php#L131).

By default it is not used in the validation message (ref https://github.com/symfony/symfony/blob/master/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntity.php#L28).

Using it in a custom message should work nevertheless.

@javiereguiluz javiereguiluz added the hasPR A Pull Request has already been submitted for this issue. label Aug 31, 2016
@wouterj wouterj closed this as completed in ee2ab69 Oct 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hasPR A Pull Request has already been submitted for this issue. Validator
Projects
None yet
Development

No branches or pull requests

2 participants