public function addForm(BaseForm $form)
    {
        $formErrorInformation = $this->getSession()->getFormErrorInformation();

        // Get form field error details
        $formFieldErrors = [];

        /** @var Form $field */
        foreach ($form->getForm()->getIterator() as $field) {
            $errors = $field->getErrors();

            if (\count($errors) > 0) {
                $formFieldErrors[$field->getName()] = [];

                /** @var FormError $error */
                foreach ($errors as $error) {
                    $formFieldErrors[$field->getName()][] = [
                        'message' => $error->getMessage(),
                        'template' => $error->getMessageTemplate(),
                        'parameters' => $error->getMessageParameters(),
                        'pluralization' => $error->getMessagePluralization()
                    ];
                }
            }
        }

        $this->set(\get_class($form) . ":" . $form->getType(), $form);

        // Set form error information
        $formErrorInformation[\get_class($form) . ":" . $form->getType()] = [
            'data'              => $this->cleanFormData($form->getForm()->getData()),
            'hasError'          => $form->hasError(),
            'errorMessage'      => $form->getErrorMessage(),
            'method'            => $this->requestStack->getCurrentRequest()->getMethod(),
            'timestamp'         => time(),
            'validation_groups' => $form->getForm()->getConfig()->getOption('validation_groups'),
            'field_errors'      => $formFieldErrors
        ];

        $this->getSession()->setFormErrorInformation($formErrorInformation);

        return $this;
    }
public function addForm(BaseForm $form)
    {
        $formErrorInformation = $this->getSession()->getFormErrorInformation();

        // Get form field error details
        $formFieldErrors = [];

        /** @var Form $field */
        foreach ($form->getForm()->getIterator() as $field) {
            $errors = $field->getErrors();

            if (\count($errors) > 0) {
                $formFieldErrors[$field->getName()] = [];

                /** @var FormError $error */
                foreach ($errors as $error) {
                    $formFieldErrors[$field->getName()][] = [
                        'message' => $error->getMessage(),
                        'template' => $error->getMessageTemplate(),
                        'parameters' => $error->getMessageParameters(),
                        'pluralization' => $error->getMessagePluralization()
                    ];
                }
            }
        }

        $this->set(\get_class($form) . ":" . $form->getType(), $form);

        // Set form error information
        $formErrorInformation[\get_class($form) . ":" . $form->getType()] = [
            'data'              => $this->cleanFormData($form->getForm()->getData()),
            'hasError'          => $form->hasError(),
            'errorMessage'      => $form->getErrorMessage(),
            'method'            => $this->requestStack->getCurrentRequest()->getMethod(),
            'timestamp'         => time(),
            'validation_groups' => $form->getForm()->getConfig()->getOption('validation_groups'),
            'field_errors'      => $formFieldErrors
        ];

        $this->getSession()->setFormErrorInformation($formErrorInformation);

        return $this;
    }
public function addForm ( BaseForm $ form ) { $ formErrorInformation = $ this -> getSession ( ) -> getFormErrorInformation ( ) ; // Get form field error details $ formFieldErrors = [ ] ; /** @var Form $field */ foreach ( $ form -> getForm ( ) -> getIterator ( ) as $ field ) { $ errors = $ field -> getErrors ( ) ; if ( \ count ( $ errors ) > 0 ) { $ formFieldErrors [ $ field -> getName ( ) ] = [ ] ; /** @var FormError $error */ foreach ( $ errors as $ error ) { $ formFieldErrors [ $ field -> getName ( ) ] [ ] = [ 'message' => $ error -> getMessage ( ) , 'template' => $ error -> getMessageTemplate ( ) , 'parameters' => $ error -> getMessageParameters ( ) , 'pluralization' => $ error -> getMessagePluralization ( ) ] ; } } } $ this -> set ( \ get_class ( $ form ) . ":" . $ form -> getType ( ) , $ form ) ; // Set form error information $ formErrorInformation [ \ get_class ( $ form ) . ":" . $ form -> getType ( ) ] = [ 'data' => $ this -> cleanFormData ( $ form -> getForm ( ) -> getData ( ) ) , 'hasError' => $ form -> hasError ( ) , 'errorMessage' => $ form -> getErrorMessage ( ) , 'method' => $ this -> requestStack -> getCurrentRequest ( ) -> getMethod ( ) , 'timestamp' => time ( ) , 'validation_groups' => $ form -> getForm ( ) -> getConfig ( ) -> getOption ( 'validation_groups' ) , 'field_errors' => $ formFieldErrors ] ; $ this -> getSession ( ) -> setFormErrorInformation ( $ formErrorInformation ) ; return $ this ; }
Add a new form to the error form context

@param BaseForm $form the errored form
@return $this
Add a new form to the error form context