php - Render controller in TWIG and show form errors -


i have indexaction , contactaction

contactaction simple form no mapped fields (formtype) below:

/**  * @route("/contact", name="contact")  * @template()  * @param request $request  * @return array  */ public function contactaction(request $request) {     $form = $this->createform(new contacttype());      $form->handlerequest($request);      if ($form->isvalid()) {         $firstname = $form->get('first_name')->getdata();         $lastname = $form->get('last_name')->getdata();         $email = $form->get('email')->getdata();         $message = $form->get('message')->getdata();     }     return array(         'form' => $form->createview()     ); } 

and render form in indexaction twig command:

{{ render(controller('russelbundle:default:contact')) }} 

everything okey, if page not reloaded, html5 validators works fine, if form have errors like: firstname length, error's not show @ all, how can do, errors showed in form indexaction? appreciated. i'm curious it's possible, , if - how ? sorry english....

rather using request passed action should master request request stack. @debreczeniandrás says, when use render(controller()) using newly created sub-request rather request passed page on load (the master request).

public function contactaction(request $request) {     $request = $this->get('request_stack')->getmasterrequest();      $form = $this->createform(new contacttype());      //... } 

Comments