Commit 0b9c93a
committed
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 class1 file changed
+6
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
0 commit comments