{% comment %} This subcategory assumes that the first questiongroup contains a checkbox question where each conditionally opens a new questiongroup. The questiongroups not appearing part of the conditions are rendered normally. This template assumes that there is one condition less than checkboxes in the first question. {% endcomment %} {% load floppyforms %} {% load list_to_columns %} {% if config.next_level == 'subcategories' %}

{{ config.label }}

{% for sub_config, sub_formsets in formsets %} {% form form using sub_config.form_template with config=sub_config formsets=sub_formsets %} {% endfor %} {% else %}
{{ config.numbering|default:'' }} {{ config.label }} {% include "form/helptext.html" with helptext=config.helptext helptext_length=config.helptext_length %} {% for questiongroup_config, questiongroup_formset in formsets %} {% if forloop.counter == 1 %}
{{ questiongroup_formset.management_form }} {% for qg_form in questiongroup_formset.forms %}
{% for field in qg_form.visible_fields %} {% with options=questiongroup_config.options|get_by_keyword:field.name label=field.label%} {% if label and options.label_position != 'placeholder' and options.label_position != 'none' %}
{% if options.helptext and options.helptext_position == 'tooltip' %} {% else %} {% endif %}
{% endif %}
{% endwith %} {% endfor %} {% for field in qg_form.hidden_fields %}{% formfield field %}{% endfor %}
{% endfor %}
{% elif forloop.counter0 > config.questiongroup_conditions|length|add:"1" %} {% form form using questiongroup_config.template with config=questiongroup_config formset=questiongroup_formset %} {% endif %} {% endfor %}
{% endif %}