{{ form_start(form) }}
<div class="accordion my-3" id="filterOrderAccordion">
    <h2 class="accordion-header" id="filterOrderHeading">
        <button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#filterOrderCollapse" aria-expanded="true" aria-controls="filterOrderCollapse">
            <strong><i class="fa fa-fw fa-filter"></i>Filtrer la liste</strong>
        </button>
    </h2>
    <div id="filterOrderCollapse" aria-labelledby="filterOrderHeading" data-bs-parent="#filterOrderAccordion">
        {% set btnSubmit = 0 %}
        <div class="accordion-body chill_filter_order container-xxl p-5 py-2">
            <div class="row my-2">
                {% if form.vars.has_search_box %}
                    <div class="col-sm-12">
                        <div class="input-group">
                            {{ form_widget(form.q) }}
                            <button type="submit" class="btn btn-misc"><i class="fa fa-search"></i></button>
                        </div>
                    </div>
                {% endif %}
            </div>

            {% if form.dateRanges is defined %}
                {% set btnSubmit = 1 %}
                {% if form.dateRanges|length > 0 %}
                    {% for dateRangeName, _o in form.dateRanges %}
                        <div class="row my-2">
                            {% if form.dateRanges[dateRangeName].vars.label is not same as(false) %}
                                {{ form_label(form.dateRanges[dateRangeName])}}
                            {% else %}
                                <div class="col-sm-4 col-form-label">{{ 'filter_order.By date'|trans }}</div>
                            {% endif %}
                            <div class="col-sm-8 pt-1">
                                <div class="input-group">
                                    <span class="input-group-text">{{ 'chill_calendar.From'|trans }}</span>
                                    {{ form_widget(form.dateRanges[dateRangeName]['from']) }}
                                    <span class="input-group-text">{{ 'chill_calendar.To'|trans }}</span>
                                    {{ form_widget(form.dateRanges[dateRangeName]['to']) }}
                                </div>
                            </div>
                        </div>
                    {% endfor %}
                {% endif %}
            {% endif %}

            {% if form.checkboxes is defined %}
                {% set btnSubmit = 1 %}
                {% if form.checkboxes|length > 0 %}
                    {% for checkbox_name, options in form.checkboxes %}
                        <div class="row my-2">
                            <div class="col-sm-4 col-form-label">{{ 'filter_order.By'|trans }}</div>
                            <div class="col-sm-8 pt-2">
                                {% for c in form['checkboxes'][checkbox_name].children %}
                                    {{ form_widget(c) }}
                                    {{ form_label(c) }}
                                {% endfor %}
                            </div>
                        </div>
                    {% endfor %}
                {% endif %}
            {% endif %}

            {% if form.entity_choices is defined %}
                {% set btnSubmit = 1 %}
                {% if form.entity_choices |length > 0 %}
                    {% for checkbox_name, options in form.entity_choices %}
                        <div class="row my-2">
                            {% if form.entity_choices[checkbox_name].vars.label is not same as(false) %}
                                {{ form_label(form.entity_choices[checkbox_name])}}
                            {% endif %}
                            <div class="col-sm-8 pt-2">
                                {% set field = form['entity_choices'][checkbox_name] %}
                                {% if field.vars.expanded %}
                                    {# Render expanded checkboxes/radios #}
                                    {% for c in field.children %}
                                        {{ form_widget(c) }}
                                        {{ form_label(c) }}
                                    {% endfor %}
                                {% else %}
                                    {# Render select dropdown #}
                                    {{ form_widget(field) }}
                                {% endif %}
                            </div>
                        </div>
                    {% endfor %}
                {% endif %}
            {% endif %}

            {% if form.user_pickers is defined %}
                {% set btnSubmit = 1 %}
                {% if form.user_pickers.children|length > 0 %}
                    {% for name, options in form.user_pickers %}
                        <div class="row my-2">
                            {% if form.user_pickers[name].vars.label is not same as(false) %}
                                {{ form_label(form.user_pickers[name]) }}
                            {% else %}
                                {{ form_label(form.user_pickers[name].vars.label) }}
                            {% endif %}
                            <div class="col-sm-8 pt-2">
                                {{ form_widget(form.user_pickers[name]) }}
                            </div>
                        </div>
                    {% endfor %}
                {% endif %}
            {% endif %}

            {% if form.single_checkboxes is defined %}
                {% set btnSubmit = 1 %}
                {% for name, _o in form.single_checkboxes %}
                    <div class="row my-2">
                        <div class="col-sm-4 col-form-label">{{ 'filter_order.By'|trans }}</div>
                        <div class="col-sm-8 pt-2">
                            {{ form_widget(form.single_checkboxes[name]) }}
                        </div>
                    </div>
                {% endfor %}
            {% endif %}

            {% if btnSubmit == 1 %}
                <div class="row my-2">
                    <button type="submit" class="btn btn-sm btn-misc"><i class="fa fa-fw fa-filter"></i>{{ 'Filter'|trans }}</button>
                </div>
            {% endif %}

        </div>
    </div>

    {% if active|length > 0 %}
        <div class="activeFilters mt-3">
            {% for f in active %}
                <span class="badge rounded-pill bg-secondary ms-1 {{ f.position }} {{ f.name }}">
                    {%- if f.label != '' %}
                        <span class="text-dark">{{ f.label|trans }}&nbsp;: </span>
                    {% endif -%}
                    {%- if f.position == 'search_box' and f.value is not null %}
                        <span class="text-dark">{{ 'filter_order.search_box'|trans ~ ' :' }}</span>
                    {% endif -%}
                    {{ f.value}}{#
                #}</span>
            {% endfor %}
        </div>
    {% endif %}
    <div>

    </div>
</div>

{% for k,v in otherParameters %}
    <input type="hidden" name="{{ k }}" value="{{ v }}" />
{% endfor %}
{{ form_end(form) }}

