prestaquiz_form_theme.html.twig 1.62 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
{% block choice_widget %}
    {% spaceless %}
        <div {{ block('widget_container_attributes') }}>
            {% if expanded %}
                {%- for child in form %}
                    <div class="form-check">
                        <input type="checkbox" id="{{ child.vars.id }}" name="{{ child.vars.full_name }}" value="{{ child.vars.value }}" class="form-check-input">
                        <label class="form-check-label" for="{{ child.vars.id }}">
                            <i class="{{ child.vars.attr['class'] }}"></i> {{ child.vars.label }}
                        </label>
                    </div>
                {%- endfor -%}
            {% else %}
                <select {{ block('widget_attributes') }}{% if multiple %} multiple="multiple"{% endif %}>
                    {% if placeholder is not none %}
                        <option value=""{% if required and value is empty %} selected="selected"{% endif %}>{{ placeholder|trans({}, translation_domain) }}</option>
                    {% endif %}
                    {% if preferred_choices|length > 0 %}
                        {% set options = preferred_choices %}
                        {{ block('choice_widget_options') }}
                        {% if choices|length > 0 and separator is not none %}
                            <option disabled="disabled">{{ separator }}</option>
                        {% endif %}
                    {% endif %}
                    {% set options = choices %}
                    {{ block('choice_widget_options') }}
                </select>
            {% endif %}
        </div>
    {% endspaceless %}
{% endblock choice_widget %}