symfony - Symfony2 global variable holding registration form -


i create , make available in twig user registration form follows:

public function registeraction() {     $registration = new registration();     $form = $this->createform(new registrationtype(), $registration, array(         'action' => $this->generateurl('account_create'),     ));      return $this->render(         'rezialrezialbundle:account:register.html.twig',         array('form' => $form->createview())     ); } 

this works fine. however, want registration form available through html button persists along several pages on website (typical register button on site's topbar).

the issue here, requires me duplicate above code creating form remaining controllers of application!

is there way make registration form available through sort of global variable?

yes, need embed controller. example, if have somepage.html.twig, in page, this:

{{ render(controller("acmebundle:controllername:register")) }} 

pay attention embedding creates subrequest. if you're not familiar request stacks, should read here.

hope helps...


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -