symfony 2.1 set form theme in controller

Recently I used setTheme function in symfony 2.0 from Symfony / Bridge / Twig / Extension / FormExtension.php, eg:

$this->get('twig')->getExtension('form')->setTheme($view, $theme);

There is no such function in sf2.1. what's the alternative way to set form theme in controller. Thanks in advance for your answer.


I checked in latest source of Symfony 2.1 and seems that it is possible by:

$this->get('twig')->getExtension('form')->renderer->setTheme($view, $theme);

Here's a complete example of generating a template with params and setting a theme to it, from the controller.

// Create the form using $this->createForm() ...
$myView = $myform->createView();
//Set the form theme
$this->get('twig')->getExtension('form')->renderer->setTheme($myView, 'XBundle:path/to/theme/myTheme.html.twig');
$content = $this->renderView('XBundle:path/to/template/myTemplate.html.twig', array('templateParam1' => $myView, 'templateParam2' => $param2));
return new Response($content);

Hope this helps. Cheers

Need Your Help

PHP can't connect to localhost XMPP server on port 5222

php xmpp ejabberd stream-socket-client

I've set up an ejabberd install locally on my Windows box, where I also have Apache, PHP and MySQL. I've also confirmed that it works great using Digsby, and have kicked the tires a bit by creating...

Want to calculate radius from one position

mysql distance radius pythagorean

I want to know how to start on my radius filter for a accommodation site. For example I want to know fields I need in my database and the data I will need in it to work out the radius. I want this ...