{% import 'macros/forms.html' as forms %}


{% macro add_group_form(form, endpoint) %}

  {% set action = url_for(endpoint) %}
  {% set form_id = 'form-add-group--1' %}

  <form action="{{ action }}" method="post", id="{{ form_id }}" enctype="multipart/form-data">

    {{ form.hidden_tag() }}

    <div class="row mb-3">
      {{ forms.field_row(form.name, 'Name') }}
    </div>

    <div class="row mb-3">
      {{ forms.field_row(form.description, 'Description') }}
    </div>

    {% for key, field in form._fields.items() if key.startswith('p_') %}
      <div class="row mb-3">
      {{ forms.field_row(field, field.label) }}
    </div>
    {% endfor %}

    <div class="row mb-3">
      <div class="col-sm-10">
        {{ form.submit() }}
      </div>
    </div>

  </form>

{% endmacro %}


{% macro edit_group_form(form, endpoint, id) %}

  {% set action = url_for(endpoint, id_=id) %}
  {% set form_id = 'form-edit-group-' ~ id %}

  <form action="{{ action }}" method="post", id="{{ form_id }}" enctype="multipart/form-data">

    {{ form.hidden_tag() }}

    <div class="row mb-3">
      {{ forms.field_row(form.description, 'Description') }}
    </div>

    {% for key, field in form._fields.items() if key.startswith('p_') %}
      <div class="row mb-3">
      {{ forms.field_row(field, field.label) }}
    </div>
    {% endfor %}

    <div class="row mb-3">
      <div class="col-sm-10">
        {{ form.submit() }}
      </div>
    </div>

  </form>

{% endmacro %}