-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Do not validate child constraints if form has no validation groups #30595
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
Conversation
…int has no validation groups
I've updated it because it has nothing to do with validation_groups being set as a callback, just a simple empty array is enough to reproduce the bug. |
Hello @maryo, thank you for opening this issue. It seems to be a doc issue to me, to disable validation you should define the |
@HeahDude Yeah. But according to this code If the callback returns And all the tests inside |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes when used with both the constraints
option. Looks good. Thanks!
Thank you @maryo. |
…n groups (maryo) This PR was merged into the 3.4 branch. Discussion ---------- Do not validate child constraints if form has no validation groups | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | License | MIT If a form has `Valid` constraint and `validation_groups` set to an empty array (to disable validation) then its children were still validated using default validation group because `FormValidator` validated the form data using the empty array validation group here https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php#L76 and then `RecursiveContextualValidator` treats the empty array as default validation group here. https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php#L86 Commits ------- f45f0d0 [Form] Preventing validation of children if parent with Valid constraint has no validation groups
If a form has
Valid
constraint andvalidation_groups
set to an empty array (to disable validation) then its children were still validated using default validation group becauseFormValidator
validated the form data using the empty array validation group herehttps://github.com/symfony/symfony/blob/master/src/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php#L76
and then
RecursiveContextualValidator
treats the empty array as default validation group here.https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php#L86