Exception/ValidationFormException.php
public function getFlattenErrors(FormInterface $form = null, $subForm = false)
    {
        $form    = $form ?: $this->form;
        $flatten = [];

        foreach ($form->getErrors() as $error) {
            if ($subForm) {
                $flatten[] = $error->getMessage();
            } else {
                $path = $error->getCause()->getPropertyPath();

                if (!array_key_exists($path, $flatten)) {
                    $flatten[$path] = [$error->getMessage()];
                    continue;
                }

                $flatten[$path][] = $error->getMessage();
            }
        }

        $subForm = true;
        foreach ($form->all() as $key => $child) {
            $childErrors = $this->getFlattenErrors($child, $subForm);

            if (!empty($childErrors)) {
                $flatten[$key] = $childErrors;
            }
        }

        return $flatten;
    }
public function getFlattenErrors(FormInterface $form = null, $subForm = false)
    {
        $form    = $form ?: $this->form;
        $flatten = [];

        foreach ($form->getErrors() as $error) {
            if ($subForm) {
                $flatten[] = $error->getMessage();
            } else {
                $path = $error->getCause()->getPropertyPath();

                if (!array_key_exists($path, $flatten)) {
                    $flatten[$path] = [$error->getMessage()];
                    continue;
                }

                $flatten[$path][] = $error->getMessage();
            }
        }

        $subForm = true;
        foreach ($form->all() as $key => $child) {
            $childErrors = $this->getFlattenErrors($child, $subForm);

            if (!empty($childErrors)) {
                $flatten[$key] = $childErrors;
            }
        }

        return $flatten;
    }
public function getFlattenErrors ( FormInterface $ form = null , $ subForm = false ) { $ form = $ form ? : $ this -> form ; $ flatten = [ ] ; foreach ( $ form -> getErrors ( ) as $ error ) { if ( $ subForm ) { $ flatten [ ] = $ error -> getMessage ( ) ; } else { $ path = $ error -> getCause ( ) -> getPropertyPath ( ) ; if ( ! array_key_exists ( $ path , $ flatten ) ) { $ flatten [ $ path ] = [ $ error -> getMessage ( ) ] ; continue ; } $ flatten [ $ path ] [ ] = $ error -> getMessage ( ) ; } } $ subForm = true ; foreach ( $ form -> all ( ) as $ key => $ child ) { $ childErrors = $ this -> getFlattenErrors ( $ child , $ subForm ) ; if ( ! empty ( $ childErrors ) ) { $ flatten [ $ key ] = $ childErrors ; } } return $ flatten ; }
Flatten form errors

@param FormInterface $form
@param boolean       $subForm

@return array
Flatten form errors