protected function getErrorsFromForm(FormInterface $form)
    {
        $errors = [];
        /** @var FormError $error */

        if($form->getErrors()->count() === 0 && $form->isRoot() && !$form->isValid()){
            $errors["_self"] = "Empty post data";
        }

        foreach ($form->getErrors() as $error) {
            $key = $error->getOrigin()->getName();
            $errors[($form->isRoot()) ? "_self" : $key] = $error->getMessage();
        }

        foreach ($form->all() as $childForm) {
            if ($childForm instanceof FormInterface) {
                if ($childErrors = $this->getErrorsFromForm($childForm)) {
                    unset($errors["_self"]);
                    $errors = array_merge_recursive($errors, $childErrors);
                }
            }
        }

        return $errors;
    }
protected function getErrorsFromForm(FormInterface $form)
    {
        $errors = [];
        /** @var FormError $error */

        if($form->getErrors()->count() === 0 && $form->isRoot() && !$form->isValid()){
            $errors["_self"] = "Empty post data";
        }

        foreach ($form->getErrors() as $error) {
            $key = $error->getOrigin()->getName();
            $errors[($form->isRoot()) ? "_self" : $key] = $error->getMessage();
        }

        foreach ($form->all() as $childForm) {
            if ($childForm instanceof FormInterface) {
                if ($childErrors = $this->getErrorsFromForm($childForm)) {
                    unset($errors["_self"]);
                    $errors = array_merge_recursive($errors, $childErrors);
                }
            }
        }

        return $errors;
    }
protected function getErrorsFromForm ( FormInterface $ form ) { $ errors = [ ] ; /** @var FormError $error */ if ( $ form -> getErrors ( ) -> count ( ) === 0 && $ form -> isRoot ( ) && ! $ form -> isValid ( ) ) { $ errors [ "_self" ] = "Empty post data" ; } foreach ( $ form -> getErrors ( ) as $ error ) { $ key = $ error -> getOrigin ( ) -> getName ( ) ; $ errors [ ( $ form -> isRoot ( ) ) ? "_self" : $ key ] = $ error -> getMessage ( ) ; } foreach ( $ form -> all ( ) as $ childForm ) { if ( $ childForm instanceof FormInterface ) { if ( $ childErrors = $ this -> getErrorsFromForm ( $ childForm ) ) { unset ( $ errors [ "_self" ] ) ; $ errors = array_merge_recursive ( $ errors , $ childErrors ) ; } } } return $ errors ; }
Build inheritance form errors

@param FormInterface $form
@return array
Build inheritance form errors