当我使用这样的代码时:
form_widget(form)
它将容器放在每一行但也放在整个表单上,我使用两个主题文件:
{% block form_row %}
{% spaceless %}
<section>
{{ form_label(form) }}
{{ form_errors(form) }}
<div>
{{ form_widget(form) }}
</div>
</section>
{% endspaceless %}
{% endblock form_row %}
这个在每一行上都可以正常工作,但是这个:
{% block form_widget %}
{% spaceless %}
{# <div {{ block('widget_container_attributes') }}> #}
{{ block('field_rows') }}
{{ form_rest(form) }}
{# </div> #}
{% endspaceless %}
{% endblock form_widget %}
不仅从表单中删除容器,还从每一行中删除容器。如何仅从表单中删除容器?
// 编辑
我得到:
<form method="post" action="/acme/web/app_dev.php/admin/users_management/3">
<label>Edit user</label>
<fieldset>
<input type="hidden" value="PUT" name="_method" />
<div id="acme_usersbundle_usertype">
<section>
<label class="required" for="acme_usersbundle_usertype_username">
Login
<span class="required"> </span>
</label>
<div>
<input id="acme_usersbundle_usertype_username" type="text" value="login" maxlength="255" required="required" name="acme_usersbundle_usertype[username]">
</div>
</section>
</div>
</fieldset>
</form>
我想得到(没有<div id="acme_usersbundle_usertype">
):
<form method="post" action="/acme/web/app_dev.php/admin/users_management/3">
<label>Edit user</label>
<fieldset>
<input type="hidden" value="PUT" name="_method">
<section>
<label class="required" for="acme_usersbundle_usertype_username">
Login
<span class="required"> </span>
</label>
<div>
<input id="acme_usersbundle_usertype_username" type="text" value="login" maxlength="255" required="required" name="acme_usersbundle_usertype[username]">
</div>
</section>
</fieldset>
</form>
使用后:
form_widget(form)