savemenico
savemenico

Reputation: 45

Twig form (from symfony) variable not found

I'm trying to get child elements (in this case radio buttons) of a widget in a form and I'm having trouble reading the variable in the for loop, but I have no problem reading it right before it.

Thanks in advance!

 {% form_theme agregarAnio _self %}

     <div id="agregarAnioDLG" title="Agregar Año">
        {{ form_start(agregarAnio) }}
        {{ form_errors(agregarAnio) }}

        {{ form_label(agregarAnio.anioDetalle) }}
        {{ form_errors(agregarAnio.anioDetalle) }}
        {{ form_widget(agregarAnio.anioDetalle) }}

            <div class='form-group'>
                {% block choice_widget_expanded %}
                    <div {{ block('widget_container_attributes') }} class='col-sm-9'>

                    {% for child in agregarAnio.anioHabilitado %} {# line 121 #}
                        {{ form_widget(child, {'attr': {'name': 'inlineRadioOptions', 'id': 'inlineRadio' ~ loop.index }}) }}
                        {{ form_label(child) }}
                    {% endfor %}
                    </div>
                {% endblock choice_widget_expanded %}

Upvotes: 0

Views: 187

Answers (1)

AJ Cerqueti
AJ Cerqueti

Reputation: 716

The block

{% block choice_widget_expanded %}

is for overwriting the theme, it's not for within the render of your form. It should be generic. I would suggest you remove that, and its endblock.

Upvotes: 1

Related Questions