{% load django_listing %}

<form{{ filters.form_attrs }}>
    {% gethiddens_filters_form listing %}

    {{ filters.form.non_field_errors }}

    {% for row in filters.form_layout %}
        <div class="form-row">
            {% for field_name,_,ending,_ in row %}
                {% filters_form_field listing field_name as field %}
                {% if field %}
                    <div class="form-field {{ filters.theme_field_class }}{% if field.errors %} errors{% endif %}">
                        {% if field.errors %}<span class="listing-icon-attention"></span> {{ field.errors }}{% endif %}
                        <div class="label_input">
                            {{ field.label_tag }} {{ field }}
                        </div>
                        {% if ending %}<span class="ending">{{ ending }}</span>{% endif %}
                        {% if field.help_text %}
                            <p class="help">{{ field.help_text|safe }}</p>
                        {% endif %}
                    </div>
                {% else %}
                    *** no filter named '{{ field_name }}' ***
                {% endif %}
            {% endfor %}
        </div>
    {% endfor %}

    <div class="form-buttons">
        {% for button in filters.form_buttons %}
            {% if button == 'reset' %}
                {% if filters.form_reset_label %}
                    <a class="filters-nav btn btn-primary reset-button"
                       href="{{ filters.get_form_reset_url }}">
                        {{ filters.form_reset_label }}
                    </a>
                {% endif %}
            {% elif button == 'submit' %}
                {% if filters.form_submit_label %}
                    <input type="submit"
                           class="filters-nav btn btn-primary submit-button"
                           value="{{ filters.form_submit_label }}"/>
                {% endif %}
            {% endif %}
        {% endfor %}
    </div>
</form>