{% load i18n admin_urls static %}


<div class="paper-formset paper-formset--stacked {{ inline_admin_formset.classes }}{% if inline_admin_formset.sortable_allowed %} paper-formset--sortable{% endif %}"
     id="{{ inline_admin_formset.formset.prefix }}-formset"
     data-formset-prefix="{{ inline_admin_formset.formset.prefix }}"
     data-formset-form-container=".paper-formset__forms"
     data-formset-form-selector=".paper-formset__form"
     data-formset-form-template="{{ inline_admin_formset.formset.prefix }}-template">

  <h3>{{ inline_admin_formset.opts.verbose_name_plural|capfirst }}</h3>
  {{ inline_admin_formset.formset.management_form }}

  {% spaceless %}
    <ul class="paper-messages messagelist mb-3">
      {% for error in inline_admin_formset.formset.non_form_errors %}
        <li class="paper-message paper-message--error">
          {{ error }}
        </li>
      {% endfor %}
    </ul>
  {% endspaceless %}

  <div class="paper-formset__forms">
    {% for inline_admin_form in inline_admin_formset %}
      {% include "admin/edit_inline/_stacked_form.html" with inline_form=inline_admin_form form_index=forloop.counter0 %}
    {% endfor %}
  </div>

  {% if inline_admin_formset.has_add_permission %}
    <template id="{{ inline_admin_formset.formset.prefix }}-template">
      {% include "admin/edit_inline/_stacked_form.html" with inline_form=inline_admin_formset.empty_form form_index='__prefix__' %}
    </template>

    <button type="button" class="paper-formset__add-form btn btn-info" data-formset-toggle="add">
      {% blocktrans with verbose_name=inline_admin_formset.opts.verbose_name|capfirst %}Add another {{ verbose_name }}{% endblocktrans %}
    </button>
  {% endif %}
</div>
