php - Inject non-const variable into all templates in Symfony2 -


i know how can inject variable twig templates. important thing variable won't const , must use logic controller prepare data. in other words, want create form using formbuilder (so must use controller functions) , make global - means access form view views (templates).

i can in way:

// part of controller return $this->render('acmebundle:homepage:index.html.twig', array(         "myform" => $myform->createview(),     )); 

and copy controller, ugly solution.

you can inject variable templates http://symfony.com/doc/current/cookbook/templating/global_variables.html. can reference service http://symfony.com/doc/current/cookbook/templating/global_variables.html#referencing-services. can there common logic.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -