Is it possible to assign two different templates to an action in Symfony 2.0? In the following code, I wanna render the IF part and ELSE part with two different template.
/**
*
* @Route("/", name="search")
* @Template("Bundle:Search:search.html.twig")
*/
public function indexAction()
{
if ($searchText == null) {
return array('form' => $form->createView(), 'form2' => $form2->createView());
} else {
return array('applicants' => $appCount, 'pagination' => $pagination, 'form' => $form->createView(),'form2' => $form2->createView());
}
}
You can’t do that with the
@Templateannotation, but you can render each manually: