<!-- Created on Wed Feb 09 11:14:00 2022 @author: alica.burlot -->
<!-- base template for formset -->
<!-- to be INCLUDED in the templates where form_base.html is extended, if you need formset -->
<!-- Check django comments for more information -->
{# Allows to display the fields with village layout #}
{% load static village_tags widget_tweaks i18n %}
{# if formset #}
{% block form_set %}
  {% if formset %}
    <div class="formset-{{ formset.prefix }} formset-group">
      {{ formset.management_form }}
      {% block formset_title %}
      {% endblock formset_title %}
      {% for form in formset %}
        <div class="{% cycle 'row1' 'row2' %} formset-row-{{ formset.prefix }} formset"
             id="formset-0">
          {% for hidden in form.hidden_fields %}
            {{ hidden }}
          {% endfor %}
          {% for field in form.visible_fields %}
            {# everything that needs to be in the loop for each field for each form in formset #}
            {% block inside_formset_field %}
            {% endblock inside_formset_field %}
            {% include "django_village/form_field_snippets/field_snippet.html" %}
          {% endfor %}
          <div class="village-mt-2w">
          <a id="remove-0" href="#" onclick="removeFormset(0)">{% translate "Delete this item" %} <span class="village-fi-delete-line" aria-hidden="true"></span>
          <br />
          <br />
        </a>
      </div>
    </div>
  {% endfor %}
  <button id="add-form"
          type="button"
          class="village-btn village-btn--secondary village-fi-add-circle-line village-btn--icon-right village-mt-1w">
    {% translate "Add an item" %}
  </button>
</div>
<br />
{% endif %}
{% endblock form_set %}
{% block extra_js %}
  <script type="text/javascript">let objectName = "{{ object_name }}";</script>
  <script src="{% static 'js/formsets.js' %}"></script>
{% endblock extra_js %}
