How do I render a form in a controller (not in a template)? I'm looking for something like:
$form = $this->createForm(...
$output = $form->render();
$output would be the html for the form.
The form is merely an object, it doesn't know what it's layout is supposed to be --- that's what the template is for. If you're in a controller extending from the default controller, you can get the HTML of a rendered template like so: $html = $this->renderView('YourAppBundle:Blah:form.html.twig', array('form' => $form->createView() ) );
where that template contains the form markup/rendering code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With