Controller/ThreadCreateController.php
/**
     * Create a new message thread.
     *
     * @param Request $request
     * @return Response
     */
Create a new message thread.
@param Request $request
@return Response
Create a new message thread . @param Request $request @return Response
public function indexAction(Request $request): Response
    {
        $form = $this->newMessageFormFactory->create();
        try {
            if ($message = $this->newFormHandler->process($form, $request)) {
                $this->addFlash('success', 'Message was successfully created!');
                $resp =  $this->redirectToRoute('fos_message_thread_new');
            } else {
                $resp = $this->render($this->templatePath, [
                    'form' => $form->createView(),
                    'data' => $form->getData(),
                ]);
            }
        } catch (SubmittedMessageValidationException $exception) {
            foreach ($exception->getFormErrors() as $error) {
                $this->addFlash('error', $error->getMessage());
            }
            $resp = $this->render($this->templatePath, [
                'form' => $form->createView(),
                'data' => $form->getData(),
            ]);
        }
        return $resp;
    }
public function indexAction ( Request $ request ) : Response { $ form = $ this -> newMessageFormFactory -> create ( ) ; try { if ( $ message = $ this -> newFormHandler -> process ( $ form , $ request ) ) { $ this -> addFlash ( 'success' , 'Message was successfully created!' ) ; $ resp = $ this -> redirectToRoute ( 'fos_message_thread_new' ) ; } else { $ resp = $ this -> render ( $ this -> templatePath , [ 'form' => $ form -> createView ( ) , 'data' => $ form -> getData ( ) , ] ) ; } } catch ( SubmittedMessageValidationException $ exception ) { foreach ( $ exception -> getFormErrors ( ) as $ error ) { $ this -> addFlash ( 'error' , $ error -> getMessage ( ) ) ; } $ resp = $ this -> render ( $ this -> templatePath , [ 'form' => $ form -> createView ( ) , 'data' => $ form -> getData ( ) , ] ) ; } return $ resp ; }
Create a new message thread.
Create a new message thread .
/**
             * @var FormError $error
             */