Reputation: 31
I am trying to create a simple form within Symfony. Not quite sure why this is not grabbing the form variable.
Receiving error:
Variable "form" does not exist src/Thinkfasttoys/MapWatchBundle/Resources/views/Default/createMapPolicy.html.twig at line 30
Controller - DefaultController.php
class DefaultController extends Controller
{
public function policyFormAction()
{
$form = $this->createFormBuilder()
->add('name', 'text')
->add('age', 'integer')
->add('save', 'submit')
->getForm()
;
return $this->render('ThinkfasttoysMapWatchBundle:Default:createMapPolicy.html.twig', array(
'form' => $form->createView(),
));
}
View - createMapPolicy.html.twig
{% block body %}
<div class="row-fluid">
<div class="span12">
<div class="widget-box">
<h4 align="center", padding="10px 0 10px 0">Create a New MAP Policy</h4>
{{ form(form) }}
<div class="container-1">
</div><!-- /.container -->
</div><!-- /.widgetbox -->
</div>
</div>
{% endblock %}
Upvotes: 1
Views: 517
Reputation: 121
In twig you have to display the form like this:
{{ form_start(form) }}
{{ form_widget(form) }}
{{ form_end(form) }}
Upvotes: 1