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
The problem is that the form bundle seems not able to correctly identify sub-forms named with snake case names during its validation process and thus fall back the displaying of their errors message to the root form. If nothing is planned to resolve this issues as it is mentioned in the previous tickets linked above, could we at least throw an error if we are creating sub-forms containing snake case names? A warning will probably save time to a bunch of developers. 😄
How to reproduce
I created a small project that illustrate the issue here.
If you checkout the commit 16a6cc1 the errors are displayed as expected:
But if you checkout the commit 49776ba, things goes wrong:
Errors corresponding to the billing form are displayed at the wrong place, and several times.
Possible Solution
The \Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationMapper::mapViolation method seems responsible for defining where violations should be rendered.
The problem is that we are comparing the violation property path that is generated from the property attribute name and from the class name of the entity that should be checked by the validation (eg: data.billingAddress.streetNumber in the example coming from my repository) with the name of the sub-form (eg: billing_address.streetNumber in my example) in the \Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationMapper::matchChild method. A solution could thus be to also check snake case variants of each name present in the violation path, but I'm not sure that such a naive fix won't add regressions somewhere else. 🤔
Additional Context
No response
The text was updated successfully, but these errors were encountered:
Symfony version(s) affected
6.0.8
Description
This issue was already observed on previous versions of Symfony :
But it's still present on Symfony 6.0.8.
The problem is that the form bundle seems not able to correctly identify sub-forms named with snake case names during its validation process and thus fall back the displaying of their errors message to the root form. If nothing is planned to resolve this issues as it is mentioned in the previous tickets linked above, could we at least throw an error if we are creating sub-forms containing snake case names? A warning will probably save time to a bunch of developers. 😄
How to reproduce
I created a small project that illustrate the issue here.
If you checkout the commit 16a6cc1 the errors are displayed as expected:
But if you checkout the commit 49776ba, things goes wrong:
Errors corresponding to the billing form are displayed at the wrong place, and several times.
Possible Solution
The
\Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationMapper::mapViolation
method seems responsible for defining where violations should be rendered.The problem is that we are comparing the violation property path that is generated from the property attribute name and from the class name of the entity that should be checked by the validation (eg:
data.billingAddress.streetNumber
in the example coming from my repository) with the name of the sub-form (eg:billing_address.streetNumber
in my example) in the\Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationMapper::matchChild
method. A solution could thus be to also check snake case variants of each name present in the violation path, but I'm not sure that such a naive fix won't add regressions somewhere else. 🤔Additional Context
No response
The text was updated successfully, but these errors were encountered: