{% load vali_tags %}
<fieldset class="{{ fieldset.classes }}">
    <div class="tile-title{% if fieldset.name %} line-head{% endif %}">
        {% if fieldset.name %}<h5>{{ fieldset.name }}</h5>{% endif %}
        {% if fieldset.description %}
            <p class="text-info small">{{ fieldset.description|safe }}</p>
        {% endif %}
    </div>
    {% vali_fieldset fieldset as fieldset %}
    {% for line in fieldset %}
        <div class="form-group {% if line.fields|length_is:'1' and line.errors %} is_invalid{% endif %}{% if not line.has_visible_field %} hidden{% endif %}{% for field in line %}{% if field.field.name %} field-{{ field.field.name }}{% endif %}{% endfor %}">
            {% if line.fields|length_is:'1' %}{% endif %}
            {% for field in line %}
                <div{% if not line.fields|length_is:'1' %} class="row col field-box{% if field.field.name %} field-{{ field.field.name }}{% endif %}{% if not field.is_readonly and field.errors %} is_invalid{% endif %}{% if field.field.is_hidden %} hidden{% endif %}"{% elif field.is_checkbox %} class="row col checkbox-row"{% else %} class="row col"{% endif %}>
                    {% if not line.fields|length_is:'1' and not field.is_readonly %}
                        {% vali_form_errors field.errors %}
                    {% endif %}
                    {% if field.is_checkbox %}
                        <div class="col-2">{{ field.label_tag }}</div>
                        <div class="col-7 px-0"> <div class="animated-checkbox"><label>{{ field.field }}<span class="label-text"></span></label></div></div>
                    {% else %}
                        <div class="col-2"> {{ field.label_tag }}</div>
                        {% if field.is_readonly %}
                            <div class="readonly">{{ field.contents }}</div>
                        {% else %}
                            <div class="col-7 px-0"> {{ field.field }}
                            {% if line.errors %}
                                <div class="invalid-feedback">
                                {% vali_form_errors line.errors %}
                                </div>
                                {% endif %}
                            </div>
                        {% endif %}
                    {% endif %}
                    {% if field.field.help_text %}
                        <p class="col-3 text-info small pt-1"><em>{{ field.field.help_text|safe }}</em></p>
                    {% endif %}
                </div>
            {% endfor %}
        </div>
    {% endfor %}
</fieldset>
