How can I insert additional text elements through a loop into the set of choices form elements in the template?

How can I move the iterable value (radio) from the outer loop to the inner one, bypassing the inner loop iteration?

How can I get the value (radio) of the outer loop. I have a nested loop that generates additional fields. The value from the outer loop. I plan to get the value from the outer loop not 30 times - but how many times in the outer loop 5 times. How can I skip the inner iteration?

I have been thinking for several days how to make such a scheme. I have a choices field. I am trying to insert section names between them. I can just have 25 choices elements. And I want to divide them into groups. For example, into several groups and implement names for each group. Something similar to a table with categories.

In the example in the figure, from 1 to 11 these are choices elements and between them the name of the group by which they are divided.

Moreover, each time the number of choices elements is different, as is the grouping.

How can I insert additional text elements through a loop into the set of choices form elements in the template?

enter image description here

 <fieldset>
    <legend>{{ form_2.name_working.label }}</legend>
    {% for radio in form_2.name_working %}
        {% for i in kol_vo_iteracii_categ|get_range %}
        <a>Cat</a>
        <div class="myradio">
            {{ radio }}
        </div>
        {% endfor %}
    {% endfor %}
</fieldset>
Вернуться на верх