{% extends 'base.html.twig' %}

{% block pagewrapper %}
{{ form_start(form) }}
    <h1 class="page-title">
    {% if mode=="update" %}
    Modification Page URL = {{entity.name}}
    {% elseif mode=="submit" %}
    Création Page URL
    {% endif %}
    </h1>

    <p>
    {{ form_widget(form.submit) }}
    {% if access=="config" %}
        <a class="btn btn-secondary" href="{{ path('app_portal_config_page_view',{id:entity.id}) }}">Annuler</a>
    {% else %}
        <a class="btn btn-secondary" href="{{ path('app_core_home',{id:entity.id}) }}">Annuler</a>
    {% endif %}

    {% if mode=="update" %}
    <a href={{ path('app_portal_'~access~'_page_delete',{'id':entity.id}) }}
        class="btn btn-danger float-end"
        data-method="delete" data-csrf="_token:{{ 'csrf' }}"
        {% if activate_widsonde %} data-sonde-rubrique="Accueil" data-sonde-page="SUPPRESSION_Page-Accueil" {% endif %}
        data-confirm="Êtes-vous sûr de vouloir supprimer cette page ?">
          Supprimer
    </a>
    {% endif %}
    </p>

    {% if app.session.flashbag.has('error') %}
        <div class='alert alert-danger' style='margin: 5px 0px'>
            <strong>Erreur</strong><br>
            {% for flashMessage in app.session.flashbag.get('error') %}
                {{ flashMessage }}<br>
            {% endfor %}
        </div>
    {% endif %}

    {% if app.session.flashbag.has('notice') %}
        <div class='alert alert-info' style='margin: 5px 0px'>
            <strong>Information</strong><br>
            {% for flashMessage in app.session.flashbag.get('notice') %}
                {{ flashMessage }}<br>
            {% endfor %}
        </div>
    {% endif %}

    <div class="form-group row clearfix">
        {% if form.roles is defined %}
            <div class="col-md-8">
        {% else %}
            <div class="col-md-12">
        {% endif %}
            <div class="card">
                <div class="card-header"><i class="fa fa-pencil-alt fa-fw"></i>Informations</div>
                <div class="card-body">  
                    {{ form_row(form.name) }}
                    {{ form_row(form.url) }}
                    <div class='alert alert-info' style='font-size: 80%;padding: 5px;margin-top: -10px;'>
                        Le mot clé #login# sera remplacé par le login de l'utilisateur</em><br>
                        Attention certains sites n'acceptent pas d'être encapsulés dans une frame.</em>
                    </div>

                    {{ form_row(form.toreload) }}
                    {{ form_row(form.roworder) }}
                    {{ form_row(form.fonticon) }}
                    {{ form_row(form.maxwidth) }}
                </div>
            </div>
        </div>

        {% if form.roles is defined %}
            <div class="col-md-4">
                <div class="card">
                    <div class="card-header"><i class="fa fa-pencil-alt fa-fw"></i>Détails</div>
                    <div class="card-body">              
                        {{ form_row(form.user) }}
                        {{ form_row(form.roles) }}
                        {{ form_row(form.groups) }}
                    </div>
                </div>
            </div>
        {% endif %}
    </div>
{{ form_end(form) }}
{% endblock %}