You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
minor #7754 Adding a tip for validation in forms without class (stoccc, javiereguiluz)
This PR was submitted for the master branch but it was merged into the 2.7 branch instead (closes#7754).
Discussion
----------
Adding a tip for validation in forms without class
When a form is mapped to an array instead of an object (i.e. a search form), every object in the array is validated with Symfony\Component\Validator\Constraints\Valid constraint.
For example a search form mapped to an array including a field of type Symfony\Bridge\Doctrine\Form\Type\EntityType will validate the choosen entity itself, resulting in an invalid form if the (already persisted) entity is, for some reasons, invalid.
References: https://github.com/symfony/symfony/blob/2.8/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php#L171:L186
I'm wondering if this behavior is a bug, while the validation of objects has this approach
"If an object is passed without explicit constraints, validate that object against the constraints defined for the object's class [eventually none]"
https://github.com/symfony/symfony/blob/2.8/src/Symfony/Component/Validator/Validator/RecursiveContextualValidator.php#L154:L169
Commits
-------
eb26f28 Minor reword
3177c1d Adding a tip for validation in forms without class
0 commit comments