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

{% macro flystock_add_form(form, endpoint, method, id) %}

    {% if id == -1 %}
        {% set action = url_for(endpoint) %}
        {% set title = 'Add Fly Stock' %}
    {% else %}
        {% set action = url_for(endpoint, id_=id) %}
        {% set title = 'Edit Fly Stock' %}
    {% endif %}

    {% set modal_id = 'modal-edit-flystock-' ~ id %}
    {% set form_id = 'form-edit-flystock-' ~ id %}


    {% call modal.modal(id=modal_id, title=title) %}

        <form action="{{ action }}" method="get" id="{{ form_id }}">

            {{ form.hidden_tag() }}

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

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

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

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

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

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

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

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

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

            <div class="row mb-3">
                {{ forms.field_row(form.chromosome_2a, 'Chromosome 2A') }}
            </div>

            <div class="row mb-3">
                {{ forms.field_row(form.chromosome_2b, 'Chromosome 2B') }}
            </div>

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

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

            <div class="row mb-3">
                {{ forms.field_row(form.chromosome_4a, 'Chromosome 4A') }}
            </div>

            <div class="row mb-3">
                {{ forms.field_row(form.chromosome_4b, 'Chromosome 4B') }}
            </div>

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

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

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

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

        </form>

        <div id="form-edit-flystock-{{ id }}-messages"></div>

        {{ forms.script_send_form(
            form=form,
            form_name=form_id,
            method=method,
            message_field=form_id ~ '-messages'
            ) }}

    {% endcall %}

{% endmacro %}