我正尝试在Symfony中创建一个简单的窗体。不太清楚为什么这不是抓住表单变量。找不到变量 - 变量“form”不存在于......
接收错误:
变量 “形式” 不存在的src/Thinkfasttoys/MapWatchBundle /资源/视图/默认/ createMapPolicy.html.twig在管线30
控制器 - 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(),
));
}
视图 - 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 %}
什么symfony的版本是您使用? –
我注意到你的渲染中指定了:'ThinkfasttoysMapWatchBundle:Default:createMapPolicy.html.twig',但是在你的错误中显示:'src/Thinkfasttoys/MapWatchBundle/Resources/views/Default/createMapPolicy.html.twig'难道你可能有两个不同的文件? –
我正在使用的版本2.7 – RKlina