{% extends "admin/base_site.html" %}
{% load i18n admin_modify customize_admin_modify adminmedia %}

{% block extrahead %}{{ block.super }}
<script type="text/javascript" src="/{{ MERENGUE_URLS_PREFIX}}/jsi18n/"></script>
{{ media }}
{% endblock %}

{% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% admin_media_prefix %}css/forms.css" />{% endblock %}

{% block coltype %}{% if ordered_objects %}colMS{% else %}colM{% endif %}{% endblock %}

{% block bodyclass %}{{ opts.app_label }}-{{ opts.object_name.lower }} change-form{% endblock %}

{% block breadcrumbs %}{% if not is_popup %}
<div class="breadcrumbs">
    {% include "admin/breadcrumbs.html" %}
</div>
{% endif %}{% endblock %}

{% block content %}
{% block object-tools %}
<ul class="object-tools">
    {% include "admin/object_tools.html" %}
    {% if not is_popup %}{% if change %}
    <li><a href="history/" class="historylink">{% trans "History" %}</a></li>
    {% if inside_basecontent %}
      <li><a href="permissions/" class="historylink">{% trans "Permissions" %}</a></li>
    {% endif %}
    {% endif %}
  {% endif %}
</ul>
{% endblock %}

<div id="content-main">
<form {% if has_file_field %}enctype="multipart/form-data" {% endif %}action="{{ form_url }}" method="post" id="{{ opts.module_name }}_form">{% block form_top %}{% endblock %}
<div>
{% if is_popup %}<input type="hidden" name="_popup" value="1" />{% endif %}
{% if save_on_top %}
  {% if inside_basecontent %}
    {% customize_submit_row %}
  {% else %}
    {% submit_row %}
  {% endif %}
{% endif %}
{% if errors %}
    <p class="errornote">
    {% blocktrans count errors|length as counter %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktrans %}
    </p>
    <ul class="errorlist">{% for error in adminform.form.non_field_errors %}<li>{{ error }}</li>{% endfor %}</ul>
{% endif %}

{% block before_field_sets %}{% endblock %}

{% for fieldset in adminform %}
  {% include "admin/includes/fieldset.html" %}
{% endfor %}

{% block after_field_sets %}{% endblock %}

{% for inline_admin_formset in inline_admin_formsets %}
    {% include inline_admin_formset.opts.template %}
{% endfor %}

{% block after_related_objects %}

<div class="module aligned">
  {% if edit_related_fields %}
    {% for field_dict in edit_related_fields %}
    {% with field_dict.field_name as field_name %}
    <div class="form-row">
    <div>
     <label for="id_edit_related_{{ field_name }}">{{ field_dict.field_label }}:</label>
     <select multiple="multiple" id="id_edit_related_{{ field_name }}" name="edit_related_{{ field_name }}">
      {% for rel_dict in field_dict.related_objects %}
      <option value="{{ rel_dict.object.id }}" {% if rel_dict.selected %}selected="selected"{% endif %}>{{ rel_dict.object }}</option>
      {% endfor %}
     </select>
     <script type="text/javascript">addEvent(window, "load", function(e) {
        SelectFilter.init("id_edit_related_{{ field_name }}", "{{ field_dict.field_label }}", 0, "{% admin_media_prefix %}"); });
     </script>
    </div>
    </div>
    {% endwith %}
    {% endfor %}
  {% endif %}
</div>
{% endblock %}

{% if inside_basecontent %}
  {% customize_submit_row %}
{% else %}
  {% submit_row %}
{% endif %}

{% if add %}
   <script type="text/javascript">if(document.getElementById("{{ adminform.first_field.auto_id }}")!=null)document.getElementById("{{ adminform.first_field.auto_id }}").focus();</script>
{% endif %}

{# JavaScript for prepopulated fields #}
{% prepopulated_fields_js %}

</div>
</form></div>
{% endblock %}
