{% extends "layout.jinja2" %}

{% block content %}
<div class="card mb-0">
    <div class="card-body">

    <form action="{{ url }}" method="post" class="form needs-validation">

        <div class="mb-3">
            <label class="form-label required-field" for="tag">Tag</label>
            <input class="form-control" name="tag" type="text" value="{{entry.tag}}" required>
        </div>

        <div class="mb-3">
            <label class="form-label required-field" for="tag_name">Intitulé</label>
            <input class="form-control" name="tag_name" type="text" value="{{entry.tag_name}}" required>
        </div>

        <div class="mb-3">					
            <a class="btn btn-light" href="{{ request.route_url('topic_edit', topic=topic) }}">
                <span class="ti ti-chevron-left"></span> Retour</a>
            <button class="btn btn-primary" type="submit" name="form.submitted">
                <span class="ti ti-check"></span> Enregistrer</button>
            {% if entry.tag != '0' %}
                <button class="btn btn-danger" type="button" data-bs-toggle="modal" data-bs-target="#confirmDelete">
                <span class="ti ti-x"></span> Supprimer</button>
            {% endif %}
        </div>


    </form>

    <!-- Modal : Confirmation SUPRESSION  -->
    <div id="confirmDelete" class="modal">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title">Supprimer le Tag</h4>
                </div>
                <div class="modal-body">
                    <!-- The form is placed inside the body of modal -->
                        <p>Etes-vous certain(e) de vouloir supprimer le Tag <b>{{ tag_name }}</b> ?</p>
                </div>
                <div class="modal-footer">
                    <form id="confirmForm" method="post">
                        <button type="submit" class="btn btn-danger" name="form.deleted">Supprimer</button>
                        <button type="button" class="btn btn-success" data-bs-dismiss="modal">Fermer</button>
                    </form>
                        </div>
                    </div>
            </div>
            </div>
        </div>
    </div>
    </div>
</div>
{% endblock %}
