Skip to content

[Form] Cannot know which contraint occurred #5525

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

Closed
tyx opened this issue Sep 17, 2012 · 2 comments
Closed

[Form] Cannot know which contraint occurred #5525

tyx opened this issue Sep 17, 2012 · 2 comments

Comments

@tyx
Copy link
Contributor

tyx commented Sep 17, 2012

Hi,

As I wrote in google groups :
https://groups.google.com/d/topic/symfony2/2yc6Ox3WSYc/discussion

Currently, it is impossible to know which constraint failed when validating a form.

But it could be very helpful to correct this lack to handle constraints failed in different way.

What do you think ? Which way to implement this feature ?

@webmozart
Copy link
Contributor

ref #7273

@webmozart
Copy link
Contributor

This is possible now that #11657 was merged. You can access the violation for a form error using the getCause() method, and the constraint that caused a violation using getConstraint():

$error->getCause()->getConstraint()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants