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
Post a Comment