{% extends request.is_ajax|yesno:"arctic/base_dialog.html,arctic/base.html" %}

{% load i18n arctic_tags staticfiles %}

{% block body_class %}
    {{ block.super }}
{% endblock %}

{% block content %}
    <div class="row">
        <div class="col">
            <div class="form-size">
            {% block form_validation %}
                {% include "arctic/partials/form_validation.html" with form=form %}
            {% endblock %}
            </div>
        </div>
    </div>
    <form action="" method="POST" enctype="multipart/form-data" class="dirty-check {{ form_display }}" data-abide novalidate>
        <fieldset type="post" class="fieldset-default arctic-card">
            <div class="{% block form_size_class %}form-size{% endblock %}">
            {% csrf_token %}
            {% block form %}
                {% block form_fields %}
                    {% include "arctic/partials/form_fields.html" with form=form %}
                {% endblock %}
            {% endblock %}

            {% block inlines %}
            {% if inlines %}
                {% for formset in inlines %}
                    {% block inlines_title %}
                        {% if formset.verbose_name %}
                            <div class="arctic-card__form-header">
                                <h4 class="arctic-card__title">{{ formset.verbose_name }}</h4>
                            </div>
                            <div class="arctic-card__placeholder arctic-card__placeholder--small"></div>
                        {% endif %}
                    {% endblock %}
                        {{ formset.management_form }}
                        {{ formset.non_form_errors }}
                    {% for form in formset %}
                        {% block inlines_form_fields %}
                            {% include "arctic/partials/form_field_inline.html" with form=form %}
                        {% endblock %}
                    {% endfor %}
                {% endfor %}
            {% endif %}
            {% endblock inlines %}

            {% block extra_forms %} {% endblock %}
            {# TODO move form-actions to it's own section #}
            {% block form_actions %}
            <div class="row justify-content-center">
                <div class="col-sm-6 col">
                    {% if links %}
                        {% for link in links %}
                            {% if object.pk %}
                                <a class="btn btn-secondary" href="{% arctic_url link.1 object.pk %}">
                            {% else %}
                                <a class="btn btn-secondary" href="{% arctic_url link.1 %}">
                            {% endif %}
                                {{ link.0 }}
                            </a>
                        {% endfor %}
                    {% endif %}
                </div>
                <div class="col-sm-6 col text-right">
                    {% block form_actions_buttons %}
                        <input type="submit" name="save" value="Submit" class="btn btn-primary" id="submit-id-save" />
                    {% endblock %}
                </div>
            </div>
            {% endblock form_actions %}
            </div>
        </fieldset>
    </form>

    {% block extra_content %}{% endblock %}
{% endblock %}
