-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Unique Entity Assert not calling __toString() method when displaying custom message #28245
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
Comments
It seems I've proposed some changes thinking it would be better like this, not being aware of the way it was documented. We could use the |
see dmaicher#1 |
@deivid11 I added a quick fix here: Is this the use-case you are having? So a related entity on the entity you are validating is not unique? See test: symfony/src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php Line 456 in ebbe9cf
|
@dmaicher yes, that is the use case and it is the fix I was looking for. Thank you! |
…ueEntityValidator (dmaicher) This PR was squashed before being merged into the 3.4 branch (closes #28252). Discussion ---------- [DoctrineBridge] support __toString as documented for UniqueEntityValidator | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #28245 | License | MIT | Doc PR | - This fixes #28245. It brings back handling `__toString` as documented for invalid values. Commits ------- 2ac883a [DoctrineBridge] support __toString as documented for UniqueEntityValidator
Symfony version(s) affected: 4.1.0
Description
According to the documentation you can use {{ value }} in message option to display a string representation of the invalid entity using the __toString method of the entity class.
I have implemented the __toString method but I'm getting this kind of message "Object of class CLASS identified by "
Possible Solution
I have checked this code but I can't figure out where is the __toString method called. It can be fixed checking if the entity class is implementing __toString before adding the default message.
The text was updated successfully, but these errors were encountered: