{% extends 'Admin/layout.html.twig' %}
{%- import 'Admin/Form/macros.html.twig' as m -%}

{% block javascripts %}
    <script>
        $(function() {
            $('.fancybox').fancybox({
                autoSize: true,
                maxWidth: '80%',
                maxHeight: '90%',
                padding: 0,
                helpers: {
                    overlay: {
                        locked: false
                    }
                },
                afterClose: function() {
                    //window.location.reload();
                }
            });

            $('.fancybox\\.iframe').fancybox({
                type: 'iframe',
                autoSize: false,
                width: 800,
                height: 500,
                maxWidth: '80%',
                maxHeight: '90%',
                padding: 0,
                helpers: {
                    overlay: {
                        locked: false
                    }
                },
                afterClose: function() {
                    //window.location.reload();
                }
            });
        });
    </script>
{% endblock %}

{% block body %}
    <header>
        <ul class="btns">
            <li class="btns-back">
                {{ m.step_back() }}
            </li>
            <li>
                <button class="btn btn-save" form="form-moduleadd">
                    {{ 'action.save'|trans({}, 'action') }}
                </button>
            </li>
        </ul>

        {% set type_readable = ('word.module.' ~ type)|trans({}, 'word') %}
        
        <h1>
            {% if form.title.vars.value is empty %}
                {{ 'action.add.module.label'|trans({'%name%': type_readable}, 'action') }}
            {% else %}
                {{ 'action.edit.module.label'|trans({'%name%': type_readable}, 'action') }} <em>{{ form.title.vars.value }}</em>
            {% endif %}
        </h1>
    </header>

    {{ form_start(form, {'attr': {'id': 'form-moduleadd', 'enctype' : 'multipart/form-data'}}) }}
        {{ form_errors(form) }}
        {{ form_errors(formModule) }}

        {{ form_row(form.type) }}
        {{ form_row(form.title) }}
        {{ form_row(form.position) }}
        {{ form_row(form.layout) }}
        {{ form_row(form.custom_class) }}
        {{ form_row(form.ordering) }}
        {{ form_row(form.is_active) }}
        {{ form_row(form.menu) }}
        
        {{ form_rest(formModule) }}
        {{ form_rest(form) }}
    {{ form_end(form) }}

    <ul class="btns">
        <li>
            <button class="btn btn-save" form="form-moduleadd">
                {{ 'action.save'|trans({}, 'action') }}
            </button>
        </li>
    </ul>
{% endblock %}
