{% extends '@CadolesCore/base.html.twig' %}

{% block localstyle %}
    #page-wrapper {
        min-height:0px !important;
    }
{% endblock %}

{% block pagewrapper %}
    {{ form_start(form) }}
        {{ form_widget(form.submit) }} <a class="btn btn-default" onClick="closeModal();">Annuler</a>
        <br><br>
    
        {% 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 %}

        {{ form_row(form.subdirectory) }}
    {{ form_end(form) }}


{% endblock %}



{% block localjavascript %}
    function closeModal() {
        window.parent.$("#mymodal").removeClass("in");
        window.parent.$(".modal-backdrop").remove();        
        window.parent.$("#mymodal").modal('hide');
    }

    $(window).load(function () {
        // On vérifie que l'execution se fait bien dans le cadre d'une modal
        if(!window.parent.$("#mymodal #framemodal").length) {
             $(location).attr('href',"{{ path('cadoles_core_home') }}");
        }

       
    });

    $('document').ready(function(){
        {% if toclose %}
            href=parent.location.href;
            parent.location.href=href;
        {% endif %}
        $("#form_subdirectory").focus();

        parent.$("#framemodal").height($("#page-wrapper").height() + 10);
    });

    $(window).resize(function () {
        parent.$("#framemodal").height($("#page-wrapper").height() + 10);
    });
{% endblock %}
