Answer the question
In order to leave comments, you need to log in
When validating fields manually, how to display all validation errors with a collection at once?
https://symfony.com/doc/current/validation.html
At the moment, let's say there is a field, email, it has 5 conditions, if the user violated 3, clicks submit the form, he returns an error at the first validation error. That is, he makes changes, submits the form again, and then on a new one, so 3 times for each error.
How can this be fixed?
If there are 2 fields, then it will validate 2 fields, but there is one error per field. It is necessary to output all errors immediately to the field, that is, the field is empty, the field must be an email, the field must be xxx length, etc. Because now the user needs to submit a new form each time until all errors are corrected.
It's strange that they solve the opposite
problem https://github.com/symfony/symfony/issues/20017
https://stackoverflow.com/questions/42469466/symfo...
Answer the question
In order to leave comments, you need to log in
Well, for example, create an array of errors in the response, which will be filled with each validator for each field, the problem is, of course, that the validator that returns an error stops further program execution, but you, try to think of a wrapper over this, and validate everything possible fields, unless, of course, there is already a ready-made solution
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question