symfony - Twig and Silex, generating dynamic forms -
i'm trying generate form on twig using 2 loops generate names , every form element. reason i'm getting expression problem, can't find issue. maybe can help.
{% l in 1..line %} <div class="row"> {% r in 1..row %} {% set form_name = "name_l_"~l~"_r_"~r~"_a" %} <div class="col-md-{{ cols }}"> {{ form_label(form.~form_name, "line: "~ l ~" total") }} {{ form_widget(form.~form_name, { attr: { 'class': 'form-control' }}) }} </div> {% endfor %} </div> {% endfor %}
you cannot append dynamic variables access members of object. need change:
form.~form_name
to this:
form[form_name]
which achieve looking for.
Comments
Post a Comment