{% extends base %}
{% load form_extras %}
{% load custom %}

{% block content %}

    <script>
    </script>

    <form id="form" method="post">
        {% csrf_token %}
        <input type="hidden" id="action" name="action" value="{{action}}"/>
        <input type="hidden" name="path" value="{{path}}"/>
        <input type="hidden" name="back" value="{{back}}"/>
        <input type="hidden" name="edit" value="{{edit}}"/>
        <input type="hidden" id="sort" name="sort" value="{{sort}}"/>
        <input type="hidden" id="form_template_sort" name="form_template_sort" value="{{form_template_sort}}"/>
        <input type="hidden" name="form_template_id" value="{{form_template.id}}"/>

        {% include "components/banners.html" %}

        {% if not read_only %}

        <div class="panel panel-default">
            <div class="panel-body">
                {% include "components/field_text_short.html" with field=form|field:'name' %}
                {% include "components/field_text_short.html" with field=form|field:'comment' %}
            </div>
            <div class="panel-footer">
                <button type="button" class="btn btn-default" onclick="go_back('{{ back }}')">Annuler</button>
                <button type="submit" class="btn btn-primary">Enregistrer</button>
                {% if grid %}
                <button type="button" class="btn btn-primary" onclick="send('clone')">Dupliquer</button>
                {% if user.is_staff %}
                <button type="button" class="btn btn-danger" onclick="open2('{% url 'django:form_template_delete' grid.id %}')">Supprimer</button>
                {% endif %}
                {% endif %}
            </div>
        </div>

        {% if action == 'update' %}

        {% include "components/table.html" with table=table_form_template_items no_paginate=True %}

        {% endif %}

        {% include "components/template.html" with template_items=form_template_items form=form_template_items_form %}

        {% endif %}

    </form>

{% endblock %}