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
I ran into a problem with errors returned from a form while using CollectionType with NotBlank constraint. When I send ONLY invalid entries in a collection, the form maps errors for each entry correctly, but additionally, it returns an error that the collection is blank. I'm not entirely sure if this makes sense and it's intentional, but it doesn't feel right to me. On the other hand, when the input array contains at least one valid entry, NotBlank error is not returned. This happens because invalid data is skipped when mapping child forms (entries) to a parent form (CollectionType), and we end up with an empty array as parent form data (PropertyPathMapper.php:82).
Symfony version(s) affected
5.4.x
Description
Hello crew,
I ran into a problem with errors returned from a form while using CollectionType with NotBlank constraint. When I send ONLY invalid entries in a collection, the form maps errors for each entry correctly, but additionally, it returns an error that the collection is blank. I'm not entirely sure if this makes sense and it's intentional, but it doesn't feel right to me. On the other hand, when the input array contains at least one valid entry, NotBlank error is not returned. This happens because invalid data is skipped when mapping child forms (entries) to a parent form (CollectionType), and we end up with an empty array as parent form data (PropertyPathMapper.php:82).
How to reproduce
This is an example form:
Errors in the form:
Errors in the form:
Possible Solution
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: