protected function getFormErrors(FormInterface $form)
    {
        $errors = [];
        foreach ($form->getErrors() as $error) {
            $errors[] = $error->getMessage();
        }
        foreach ($form->all() as $child) {
            if (!$child->isValid()) {
                $errors[$child->getName()] = $this->getFormErrors($child);
            }
        }

        return $errors;
    }
protected function getFormErrors(FormInterface $form)
    {
        $errors = [];
        foreach ($form->getErrors() as $error) {
            $errors[] = $error->getMessage();
        }
        foreach ($form->all() as $child) {
            if (!$child->isValid()) {
                $errors[$child->getName()] = $this->getFormErrors($child);
            }
        }

        return $errors;
    }
protected function getFormErrors ( FormInterface $ form ) { $ errors = [ ] ; foreach ( $ form -> getErrors ( ) as $ error ) { $ errors [ ] = $ error -> getMessage ( ) ; } foreach ( $ form -> all ( ) as $ child ) { if ( ! $ child -> isValid ( ) ) { $ errors [ $ child -> getName ( ) ] = $ this -> getFormErrors ( $ child ) ; } } return $ errors ; }
Returns all the errors from form into array.

@param FormInterface $form The form

@return array
Returns all the errors from form into array .