Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make form_rest() not display a field with Symfony2?

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 ?

like image 255
Ilan Coulon Avatar asked May 13 '12 07:05

Ilan Coulon


People also ask

What is Form_widget?

form_widget(form_view, variables) is a Twig function to render the HTML widget of a given field. If you apply this to an entire form or collection of fields, each underlying form row will be rendered.

What is form rendering?

This form is used to export the currently displayed graphics scene to an image file or to a geometric scene description file suitable for use by one of several external renderers, which can produce a final image.


1 Answers

Another option is to explicitly mark the field as rendered:

{% do form.contenu.setRendered %} 
like image 84
Francesc Rosas Avatar answered Oct 09 '22 06:10

Francesc Rosas