symfony - Customizing Symfony2 forms -
i started using symfony2 framework.
i apologize incorrect terminology using.
i customize how forms presented in application.
more specifically, in twig file rendering entire form with
{{ form(forms) }}
i customize layout of form. know each row of form can expanded as
{{ form_start(forms) }} //... <div> {{ form_label(forms.field) }} {{ form_errors(forms.field) }} {{ form_widget(forms.field) }} </div> //... {{ form_end(forms) }}
with form written in format add needed customization layout.
here problem: form not have pre-defined number of rows, these depend on values stored in database. in twig this
{{ form_start(forms) }} {% field in forms %} <div> {{ form_label(forms.field) }} {{ form_errors(forms.field) }} {{ form_widget(forms.field) }} </div> {% endfor %} {{ form_end(forms) }}
unfortunately, loop not work. looked (how customize form rendering), think not suit case (does it?).
any suggestion?
thank in advance help.
you need customize form_row method http://symfony.com/doc/current/cookbook/form/form_customization.html#customizing-the-form-row
// my_form.html.twig {% extends 'form_div_layout.html.twig' %} {% block form_row %} <div> {{ form_label(form) }} {{ form_errors(form) }} {{ form_widget(form) }} </div> {% endblock form_row %} // view.html.twig {% form_theme form 'my_form.html.twig' %} {{ form_start(form) }}
Comments
Post a Comment