I have an embedded controller as described at Symfony's website. http://symfony.com/doc/current/templating/embedding_controllers.html
The only difference is that my controller has a form. All is rendered correctly but once the form is submitted, the request is always empty. Since the request is empty, the $form->isValid() and $form->isSubmitted() always return false.
Please find below my code:
Twig:
{{ form_start(form) }}
{{ form_widget(form) }}
{{ form_end(form) }}
Controller:
public function myEmbeddedAction(Request $request)
{
$template ="myTwig.html.twig";
$supportTicket = new SupportTicket();
$form = $this->createForm('AppBundle\Form\SupportTicketType', $supportTicket);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
// success
}
return $this->render($template, array(
'supportTicket' => $supportTicket,
'form' => $form->createView()
));
}
Embedding the controller in my layout:
{{ render(controller('AppBundle:Default:myEmbedded')) }}
The request at the embedded action has always the same value:
{"attributes":{},"request":{},"query":{},"server":{},"files":{},"cookies":{},"headers":{}}
However, if I access the embedded controller directly through the URL and fill the form, it works. How can I get the form to work inside of my embedded controller?