sergeda
sergeda

Reputation: 369

Symfony2 how to render all rows of form in twig

I built a form in symfony with this code:

foreach ( $options as $field => $title ) {
    $form->add( $field, 'text', array('label' => $title, 'mapped' => false ) );
}

And I can't find a way to render all the rows of this form in twig.

Is this possible?

Upvotes: 2

Views: 1574

Answers (2)

sergeda
sergeda

Reputation: 369

Ok. I've found how to do this. In Twig:

{% for child in form.children|keys %} {{ form_row(attribute(form.children,child)) }} {% endfor %}

Upvotes: 5

Bactisme
Bactisme

Reputation: 1683

Are you looking for something like this : ?

{{ form(form) }}
or
{{ form_widget(form) }}

http://symfony.com/doc/current/cookbook/form/form_customization.html

Upvotes: 1

Related Questions