{% load arctic_tags %}

<div class="row align-center">
    <div class="small-12 medium-8 columns">
        {% if layout %}
            {% for index, layout_item in layout.items %}
                {% if layout_item.fieldset.collapsible %}
                    <fieldset class="fieldset-default collapse">
                {% else %}
                    <fieldset class="fieldset-default">
                {% endif %}
                {% if layout_item.fieldset.title %}
                        <legend>{{ layout_item.fieldset.title }}</legend>
                {% endif %}

                {% if layout_item.fieldset.description %}
                    <p>{{ layout_item.fieldset.description }}</p>
                {% endif %}

                {% for row in layout_item.rows %}
                    <div class="row {% if field.errors %}error{% endif %}">
                        {% if row|typename == 'dict' %}
                            {% include 'arctic/partials/form_field.html' with field=row.field style=style column=row.column %}
                        {% else %}
                            {% for field in row %}
                                {% include 'arctic/partials/form_field.html' with field=field.field style=style column=field.column %}
                            {% endfor %}
                        {% endif %}
                    </div>
                {% endfor %}

                </fieldset>
            {% endfor %}

        {% else %}
            <fieldset class="fieldset-default">
            {% for field in form %}
                {% include 'arctic/partials/form_field.html' with field=field%}
            {% endfor %}
            </fieldset>

        {% endif %}
    </div>
</div>
