To debug a form, use $form->getErrorsAsString() instead of $form->getErrors() .
$form->getErrorsAsString() should only be used to debug the form ... it will contain errors for each child, which does not apply to $form->getErrors() .
As Peter mentions, $form->getErrors() will not return the sum of all errors of child forms.
To understand how a form can be invalid and have getErrors () returning an empty array, you can take a look at the isValid () method's symfony form class. As you can see, there are two cases where the form is invalid, the first test for the general form and the second random test for each child.
public function isValid() {
Therefore, each child of the form may contain an error, but $form->getErrors() itself will not return all errors. Given a form that has many children, you usually have $ form-> getErrors () with a CSRF error if the CSRF is incorrect.
Mick Dec 29 2018-12-12T00: 00Z
source share