{% extends '/admin/menu_left_admin.html.twig' %}

{% block title %} Modification d'un agent {% endblock %}

{% block main %}

            {% if errors|length > 1 %}
                <div class="alert alert-danger">
                    Erreurs :
                    <ul>
                        {% for flashMessage in errors %}
                            <li>{{ flashMessage }}</li>
                        {% endfor %}
                    </ul>
                </div>
            {% else %}
                {% for flashMessage in errors %}
                    <div class="alert alert-danger">
                        Erreur :  {{ flashMessage }}
                    </div>
                {% endfor %}
            {% endif %}


    {#{{ form_start(form) }}#}
    {#{{ form_row(form.nom) }}#}
    {#{{ form_row(form.prenom) }}#}
    {#{{ form_row(form.email) }}#}
    {#{{ form_row(form.telephone) }}#}
    {#{{ form_row(form.agences) }}#}

    {#<button type="submit" class="btn btn-success">Submit</button>#}
    {#{{ form_end(form) }}#}

    <div class="bloc-title mb-16">
        <h2 class="align-middle">Modification de l'agent {{ agent.email }}</h2>
    </div>
    <div class="row m-0">
        <div class="col-xs-5 plr-16 pt-16 pb-16 background-white">

            {{ form_start(form, { 'attr': { 'novalidate': 'novalidate' }}) }}
            <div class="form-group mb-16">
                {{ form_label(form.nom) }}
                {{ form_widget(form.nom, { 'attr': { 'class': 'inscription plr-16' }}) }}
                {{ form_errors(form.nom) }}
            </div>
            <div class="form-group mb-16">
                {{ form_label(form.prenom) }}
                {{ form_widget(form.prenom, { 'attr': { 'class': 'inscription plr-16' }}) }}
                {{ form_errors(form.prenom) }}
            </div>
            <div class="form-group mb-16">
                {{ form_label(form.email) }}
                {{ form_widget(form.email, { 'attr': { 'class': 'inscription plr-16' }}) }}
                {{ form_errors(form.email) }}
            </div>
            <div class="form-group mb-16">
                {{ form_label(form.telephone) }}
                {{ form_widget(form.telephone, { 'attr': { 'class': 'inscription plr-16' }}) }}
                {{ form_errors(form.telephone) }}
            </div>

            <div class="text-right">
                <a href="{{ path('agents_list') }}" class="button-square-prev">{{ "BACK"|trans }}</a>
                <button id="button1" onclick="return change_text_button()" type="submit" class="button-square" >Valider</button>
            </div>
            {{ form_end(form) }}

        </div>
    </div>

{% endblock %}

{% block  javascript %}
{{ parent()}}
<script type="text/javascript">
function change_text_button(){
        document.getElementById("button1").textContent = "Chargement...";
    }
</script>

{% endblock %}