简体   繁体   English

Twig / Symfony没有渲染form_widget

[英]Twig/Symfony not rendering form_widget

I have a twig template ( home.twig ), and I'm using 我有一个树枝模板( home.twig ),我正在使用

{{ render(controller('WebsiteUserBundle:Registration:register',{ 'template': 'popup'} )) }}

inside that template to render another template ( login.twig ), which is used to login the user from a popup. 在该模板内部渲染另一个模板( login.twig ),该模板用于从弹出窗口登录用户。

The problem is that the form_widget isn't rendered, but the form_label is. 问题是, form_widget不呈现,但form_label是。

This is part of my login template: 这是我的登录模板的一部分:

<div class="row-fluid">
    {{ form_label(form.email, 'Email:')}}
    {{ form_widget(form.email, { 'attr': {'class': 'span12'} }) }}
</div>

And by "it's not rendered", I mean that there isn't even an empty div or input next to the label element in the DOM. 所谓“未呈现”,是指DOM中的label元素旁边甚至没有空的divinput

Why is this happening? 为什么会这样呢?

if you get only form_widget without extra params, like this : 如果您只获得form_widget而没有额外的参数,例如:

{{ form_widget(form.email) }}

do you have more informations or any output ? 您是否有更多信息或任何输出?

I had the same issue and was because I had the follow sentence before the form_widget 我有同样的问题,是因为我在form_widget之前有一个跟随句

{{ form_rest(form) }}

Check that the form_rest be after of all your form_widget. 检查form_rest是否在所有form_widget之后。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM