如何使用 Symfony2 使 form_rest() 不显示字段? [英] How to make form_rest() not display a field with Symfony2?

查看:20
本文介绍了如何使用 Symfony2 使 form_rest() 不显示字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始使用 Symfony2 但我遇到了一些问题.我想手动渲染字段,但它不起作用,因为我渲染的字段也用 form_rest() 函数显示,所以我有两个相同的字段.

这是我的代码:

{{ form_errors(form.contenu) }}<textarea id="{{ form.contenu.vars.id }}" name="{{ form.contenu.vars.full_name }}">{{ form.contenu.vars.value }}</textarea>

而且,在表格的最后,我必须把这个:

{{ form_rest(form) }}

但它显示contenu"字段:(

你知道问题出在哪里了吗?

解决方案

另一种选择是将字段显式标记为已呈现:

{% 做 form.contenu.setRendered %}

I've started to use Symfony2 but I've some problems. I wanted to render fields by hand but it doesn't work because my field yet rendered by me is displayed with the form_rest() function too, so I have two same fields.

Here is my code :

<div>
     {{ form_errors(form.contenu) }}
     <textarea id="{{ form.contenu.vars.id }}" name="{{ form.contenu.vars.full_name }}">{{ form.contenu.vars.value }}</textarea>
</div>

And, at the form's end, I must put this :

{{ form_rest(form) }}

But it displays the "contenu" field :(

Do you have an idea of what's the problem ?

解决方案

Another option is to explicitly mark the field as rendered:

{% do form.contenu.setRendered %}

这篇关于如何使用 Symfony2 使 form_rest() 不显示字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆