Form/FormErrorHandler.php
public function getErrorMessages(FormInterface $form, bool $useLabels = false, array $errors = []):array
    {
        if ($form->count() > 0) {
            foreach ($form->all() as $child) {
                if (!$child->isValid()) {
                    $errors = $this->getErrorMessages($child, $useLabels, $errors);
                }
            }
        }

        foreach ($form->getErrors() as $error) {
            if ($useLabels) {
                $fieldNameData = $this->getErrorFormLabel($form);
            } else {
                $fieldNameData = $this->getErrorFormId($form);
            }

            $fieldName = $fieldNameData;

            if ($useLabels) {
                /**
                 * @ignore
                 */
                $fieldName = $this->translator->trans($fieldNameData['label'], array(), $fieldNameData['domain']);
            }

            $errors[$fieldName] = $error->getMessage();
        }

        return $errors;
    }
public function getErrorMessages(FormInterface $form, bool $useLabels = false, array $errors = []):array
    {
        if ($form->count() > 0) {
            foreach ($form->all() as $child) {
                if (!$child->isValid()) {
                    $errors = $this->getErrorMessages($child, $useLabels, $errors);
                }
            }
        }

        foreach ($form->getErrors() as $error) {
            if ($useLabels) {
                $fieldNameData = $this->getErrorFormLabel($form);
            } else {
                $fieldNameData = $this->getErrorFormId($form);
            }

            $fieldName = $fieldNameData;

            if ($useLabels) {
                /**
                 * @ignore
                 */
                $fieldName = $this->translator->trans($fieldNameData['label'], array(), $fieldNameData['domain']);
            }

            $errors[$fieldName] = $error->getMessage();
        }

        return $errors;
    }
public function getErrorMessages ( FormInterface $ form , bool $ useLabels = false , array $ errors = [ ] ) : array { if ( $ form -> count ( ) > 0 ) { foreach ( $ form -> all ( ) as $ child ) { if ( ! $ child -> isValid ( ) ) { $ errors = $ this -> getErrorMessages ( $ child , $ useLabels , $ errors ) ; } } } foreach ( $ form -> getErrors ( ) as $ error ) { if ( $ useLabels ) { $ fieldNameData = $ this -> getErrorFormLabel ( $ form ) ; } else { $ fieldNameData = $ this -> getErrorFormId ( $ form ) ; } $ fieldName = $ fieldNameData ; if ( $ useLabels ) { /**
                 * @ignore
                 */ $ fieldName = $ this -> translator -> trans ( $ fieldNameData [ 'label' ] , array ( ) , $ fieldNameData [ 'domain' ] ) ; } $ errors [ $ fieldName ] = $ error -> getMessage ( ) ; } return $ errors ; }
Returns an array with form fields errors

@param FormInterface $form
@param bool $useLabels
@param array $errors
@return array
Returns an array with form fields errors