{% extends "brillixy/base.html" %}
{% load brillixytags admin_urls admin_list i18n %}
{% load url from future %}

{% load i18n admin_static admin_modify %}
{# load admin_urls #}

{% block extrastyle %}
    <link href="{{ STATIC_URL }}brillixy/css/changeform.css" rel="stylesheet" type="text/css" />
{% endblock %}

{% block extrahead %}
    {{ block.super }}
    <script type="text/javascript" src="{% url 'admin:jsi18n' %}"></script>
    {{ media }}
    <script type="text/javascript" src="{{ STATIC_URL }}brillixy/js/changeform.js"></script>
{% endblock %}

{% block breadcrumbs-middle %}
    <li>
        <span class="divider">/</span> {% if has_change_permission %}<a href="{% url opts|admin_urlname:'changelist' %}">{{ opts.verbose_name_plural|capfirst }}</a>{% else %}{{ opts.verbose_name_plural|capfirst }}{% endif %}
    </li>
{% endblock %}

{% block breadcrumbs-title %}
    <li><span class="divider">/</span> <strong>{{ title }}{% if original %}: {{ original }}{% endif %}</strong></li>
{% endblock %}

{% block content_title %}{% endblock %}

{% block content %}
<div id="content-main">
    <form {% if has_file_field %}enctype="multipart/form-data" {% endif %}action="{{ form_url }}" method="post" id="{{ opts.model_name }}_form" class="form-horizontal">

        <!-- Buttons on top -->
        {% if save_on_top %}
        {% include "brillixy/_object_tools.html" %}
        <hr>
        {% endif %}

        <div class="form-body">
            <!-- Hidden -->
            {% csrf_token %}
            {% if is_popup %}<input type="hidden" name="_popup" value="1" />{% endif %}

            <!-- Form info -->
            <div class="alert form-info" style="display: none;">{% block form_top %}{% endblock %}</div>
            
            <!-- Errors -->
            {% if errors %}
                <div class="alert alert-error form-errors">
                    <span>{% blocktrans count counter=errors|length %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}</span>
                    {{ adminform.form.non_field_errors }}
                </div>                
            {% endif %}

            <!-- Fields -->
            {% block field_sets %}
            {% for fieldset in adminform %}
                {% if not forloop.first %}<hr>{% endif %}
                {% include "brillixy/_fieldset.html" %}
            {% endfor %}
            {% endblock %}

            {% block after_field_sets %}{% endblock %}

            <!-- Related objects -->
            {% block inline_field_sets %}
            {% for inline_admin_formset in inline_admin_formsets %}
                {% include inline_admin_formset.opts.template %}
            {% endfor %}
            {% endblock %}
            {% block after_related_objects %}{% endblock %}

            <!-- Extra JS -->
            {% if adminform.first_field and add %}
           <script type="text/javascript">document.getElementById("{{ adminform.first_field.id_for_label }}").focus();</script>
            {% endif %}
            {% prepopulated_fields_js %}
        </div>

        <!-- Buttons -->
        <hr>
        {% include "brillixy/_object_tools.html" %}
    </form>
</div>
{% endblock %}