-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Getting FormErrors indexed by validation-group ? #5050
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
Partial copy of my reply from StackOverflow: Unfortunately this is currently not possible without hacking the core. The problem is that Even if we added this feature, the problem would remain that a constraint is only evaluated once if it belongs to multiple groups that are validated at once. The violation would then only store the first group, even though it would have failed in the other groups too. |
If the binding process loops on every constraints of each validation-group (but validate them only if not done yet), it must be possible to keep tracks on every failled constraint in each group ? Can we state that, if a validation constraint fails in a validation group, it will fail for other group it's in ? |
Not really, because the validation process does not control and modify the violations added by each validator. What you ask for is to change the violation afterwards to also include the groups that it would have occurred in. I don't like that smell...
Correct :) (unless you have a custom constraint that does funky stuff based on the current group, which I absolutely discourage) |
The FormError now has a reference to the ConstraintViolation causing it (through |
@stof Correct. |
… (webmozart) This PR was merged into the 2.6-dev branch. Discussion ---------- [Validator] Added ConstraintViolation::getConstraint() | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #5050 | License | MIT | Doc PR | - This PR adds a `getConstraint()` method to the `ConstraintViolation` in order to access the constraint causing the violation. Related to #7276, #7273 and #9691. Commits ------- ce1d209 [Validator] Added ConstraintViolation::getConstraint()
I use validation-groups on multi-tabbed form and I'd like to know the first failed tabbed part into directly display the corresponding tab. To do that, I need to know for each validation group if it's validated or not. How is it possible to implement this feature in Symfony, and feasable with the new 2.1 architecture ?
The text was updated successfully, but these errors were encountered: