{% extends "crud/edit.html.twig" %}
{% block formContent %}
    <ul class="nav nav-tabs">
        <li class="active"><a href="#tab-geral" data-toggle="tab">{% trans %}Geral{% endtrans %}</a></li>
        <li><a href="#tab-permissao" data-toggle="tab">{% trans %}Permissões{% endtrans %}</a></li>
    </ul>
    <div class="tab-content">
        <div id="tab-geral" class="tab-pane active">
            <div class="form-group required">
                <label for="nome">{% trans %}Nome{% endtrans %}</label>
                <input id="nome" type="text" name="nome" class="form-control" value="{{ model.nome }}" maxlength="50" />
            </div>
            <div class="form-group required">
                <label for="descricao">{% trans %}Descrição{% endtrans %}</label>
                <textarea id="descricao" name="descricao" class="form-control" rows="5" maxlength="150">{{ model.descricao }}</textarea>
            </div>
            {% if model.id == 0 or model.left != 1 %}
            <div class="form-group required">
                <label for="pai">{% trans %}Pai{% endtrans %}</label>
                <select id="pai" name="id_pai" class="form-control">
                    <option value="">{% trans %}Selecione{% endtrans %}</option>
                    {% for item in pais %}
                    <option value="{{ item.id }}" {% if item.id == modelParent.id %}selected="selected"{% endif %}>{{ item.nome }}</option>
                    {% endfor %}
                </select>
            </div>
            {% endif %}
        </div>
        <div id="tab-permissao" class="tab-pane">
            <h3>{% trans %}Módulos{% endtrans %}</h3>
            <div class="permissoes">
                {% for k,v in tipos %}
                <div class="modulos">
                    <h4>{{ v }}</h4>
                    <ul>
                        {% for modulo in modulos[k] %}
                        <li>
                            <input id="modulo-{{ modulo.id }}" type="checkbox"
                                   name="permissoes[]" value="{{ modulo.id }}"
                                   {% for permissao in permissoes %}
                                        {% if permissao.modulo.id == modulo.id %}
                                            checked="checked"
                                        {% endif %}
                                   {% endfor %}
                            />
                            <label for="modulo-{{ modulo.id }}">{{ modulo.nome }}</label>
                        </li>
                        {% endfor %}
                    </ul>
                </div>
                {% endfor %}
            </div>
        </div>
    </div>
{% endblock %}