{% use 'bootstrap_3_layout.html.twig' %}

{% block collection_widget %}
    {% if prototype is defined %}
        {% set attr = attr|merge({'data-prototype': form_row(prototype)}) %}
        {% set attr = attr|merge({'data-prototype-name': prototype.vars.name}) %}
    {% endif %}
    {% set attr = attr|merge({'data-allow-add': allow_add ? 1 : 0}) %}
    {% set attr = attr|merge({'data-allow-remove': allow_delete ? 1 : 0 }) %}
    {% set attr = attr|merge({'data-name-prefix': full_name}) %}
    {{ block('form_widget') }}
{% endblock collection_widget %}

{% block local_business_opening_hours_widget %}
    <div class="panel panel-default">
        <div class="panel-body">
            <div class="row">
                <div class="col-md-6">
                    {{ form_row(form.dayOfWeek) }}
                </div>
                <div class="col-md-3">
                    {{ form_row(form.opens) }}
                </div>
                <div class="col-md-3">
                    {{ form_row(form.closes) }}
                </div>
            </div>
            <div class="text-right">
                <a href="#" class="collection-remove btn btn-danger btn-sm">
                    <i class="fa fa-trash" aria-hidden="true"></i> Supprimer cette plage
                </a>
            </div>
        </div>
    </div>
{% endblock local_business_opening_hours_widget %}

{% block product_variant_widget %}
    {% set scheduledAvailabilityVersion = form.vars.scheduledAvailabilityBusinessVersion|default(null) %}
    {% set variantCollapseId = form.vars.id ~ '_collapse' %}
    {% set variantHeadingId = form.vars.id ~ '_heading' %}
    {% set variantTitle = 'Nouvelle variante' %}
    {% if form.vars.data and form.vars.data.type %}
        {% if form.vars.data.type.info %}
            {% set variantTitle = form.vars.data.type.name ~ ' (' ~ form.vars.data.type.info ~ ')' %}
        {% else %}
            {% set variantTitle = form.vars.data.type.name %}
        {% endif %}
    {% endif %}
    <div class="panel panel-default product-variant-panel" data-variant-panel>
        <div class="panel-heading" id="{{ variantHeadingId }}">
            <h4 class="panel-title">
                <a class="collapsed product-variant-toggle"
                   data-toggle="collapse"
                   href="#{{ variantCollapseId }}"
                   style="display:block; margin:-10px -15px; padding:10px 15px;"
                   aria-expanded="false"
                   aria-controls="{{ variantCollapseId }}">
                    <span data-variant-title>{{ variantTitle }}</span>
                    {% if scheduledAvailabilityVersion %}
                        <span class="label label-warning" style="margin-left: 8px;">
                            <i class="fas fa-calendar-alt"></i> État planifié
                        </span>
                    {% endif %}
                    <i class="fa fa-chevron-right pull-right" data-variant-chevron aria-hidden="true"></i>
                </a>
            </h4>
        </div>
        <div id="{{ variantCollapseId }}"
             class="panel-collapse collapse"
             data-variant-collapse
             aria-labelledby="{{ variantHeadingId }}">
            <div class="panel-body">
                <div class="row" style="margin-bottom: 20px;">
                    <div class="col-md-12 actions text-right">
                        {% if is_granted('ROLE_ADMIN') or is_granted('ROLE_PRODUCT') %}
                            <a href="#" class="collection-up btn btn-default"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
                            <a href="#" class="collection-down btn btn-default"><i class="fa fa-arrow-down" aria-hidden="true"></i></a>
                            <a href="#" class="collection-remove btn btn-default"><i class="fa fa-trash" aria-hidden="true"></i></a>
                            {{ form_widget(form.position) }}
                        {% else %}
                            <a href="#" class="collection-up btn btn-default hidden"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
                            <a href="#" class="collection-down btn btn-default hidden"><i class="fa fa-arrow-down" aria-hidden="true"></i></a>
                            <a href="#" class="collection-remove btn btn-default hidden"><i class="fa fa-trash" aria-hidden="true"></i></a>
                        {% endif %}
                    </div>
                </div>
                <div class="panel panel-info">
                    <div class="panel-heading">Sélection du type</div>
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-md-4">
                                {% if is_granted('ROLE_ADMIN') or is_granted('ROLE_PRODUCT') %}
                                    {{ form_row(form.type) }}
                                {% elseif form.vars.data is not null %}
                                    <h4>{{ form.vars.data.type.name }}</h4>
                                {% endif %}
                            </div>
                            <div class="col-md-4">
                                {% if is_granted('ROLE_ADMIN') or is_granted('ROLE_PRODUCT') %}
                                    {{ form_row(form.lot) }}
                                {% endif %}
                            </div>
                            <div class="col-md-4">
                                {% if is_granted('ROLE_ADMIN') or is_granted('ROLE_PRODUCT') %}
                                    {{ form_row(form.sku) }}
                                    {% if form.vars.effectiveSku|default(null) %}
                                        <p class="help-block">{{ 'product_variant.sku.effective'|trans({}, 'form') }} : <code>{{ form.vars.effectiveSku }}</code></p>
                                    {% endif %}
                                {% endif %}
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="well well-sm" style="margin-bottom: 0;">
                                    <div class="row">
                                {% if is_granted('ROLE_ADMIN') or is_granted('ROLE_PRODUCT') %}
                                            <div class="col-sm-2">
                                                {{ form_row(form.byDefault) }}
                                            </div>
                                            <div class="col-sm-2">
                                                {{ form_row(form.unPublished) }}
                                            </div>
                                            <div class="col-sm-2">
                                                {{ form_row(form.soldOut) }}
                                            </div>
                                {% else %}
                                            <div class="col-sm-3">
                                                {{ form_row(form.unPublished) }}
                                            </div>
                                            <div class="col-sm-3">
                                                {{ form_row(form.soldOut) }}
                                            </div>
                                {% endif %}
                                {% if form.scheduledUnPublished is defined %}
                                            <div class="col-sm-6">
                                    {% if scheduledAvailabilityVersion %}
                                                    <span class="label label-warning" style="display: inline-block; margin-right: 8px; padding: 7px 9px; vertical-align: middle;">
                                                        <i class="fas fa-calendar-alt"></i>
                                                        {{ scheduledAvailabilityVersion.validFrom|date('d/m/Y H:i') }}
                                                        - Dépublié : {{ scheduledAvailabilityVersion.snapshot.unPublished|default(false) ? 'Oui' : 'Non' }}
                                                        - Épuisé : {{ scheduledAvailabilityVersion.snapshot.soldOut|default(false) ? 'Oui' : 'Non' }}
                                                    </span>
                                    {% endif %}
                                    <button type="button" class="btn {% if scheduledAvailabilityVersion %}btn-warning{% else %}btn-default{% endif %}" data-toggle="modal" data-target="#{{ form.vars.id }}_availability_schedule_modal">
                                        <i class="fas fa-calendar-alt"></i>
                                        {% if scheduledAvailabilityVersion %}Voir la planification{% else %}Planifier l'état{% endif %}
                                    </button>
                                            </div>
                                {% endif %}
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                {% if form.scheduledUnPublished is defined %}
                    <div class="modal fade" id="{{ form.vars.id }}_availability_schedule_modal" tabindex="-1" role="dialog" aria-labelledby="{{ form.vars.id }}_availability_schedule_modal_title">
                        <div class="modal-dialog" role="document">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Fermer"><span aria-hidden="true">&times;</span></button>
                                    <h4 class="modal-title" id="{{ form.vars.id }}_availability_schedule_modal_title">
                                        <i class="fas fa-calendar-alt"></i> Planifier l'état du variant
                                    </h4>
                                </div>
                                <div class="modal-body">
                                    {% if scheduledAvailabilityVersion %}
                                        <div class="alert alert-warning">
                                            <strong>Planification existante</strong><br>
                                            Publication prévue le {{ scheduledAvailabilityVersion.validFrom|date('d/m/Y H:i:s') }}.<br>
                                            Dépublié : {{ scheduledAvailabilityVersion.snapshot.unPublished|default(false) ? 'Oui' : 'Non' }}<br>
                                            Épuisé : {{ scheduledAvailabilityVersion.snapshot.soldOut|default(false) ? 'Oui' : 'Non' }}
                                        </div>
                                        {{ form_row(form.scheduledUnPublished, { attr: { disabled: 'disabled' } }) }}
                                        {{ form_row(form.scheduledSoldOut, { attr: { disabled: 'disabled' } }) }}
                                        {{ form_row(form.scheduledAvailabilityValidFrom, { attr: { disabled: 'disabled' } }) }}
                                    {% else %}
                                        {{ form_row(form.scheduledUnPublished) }}
                                        {{ form_row(form.scheduledSoldOut) }}
                                        {{ form_row(form.scheduledAvailabilityValidFrom) }}
                                    {% endif %}
                                </div>
                                <div class="modal-footer">
                                    {% if scheduledAvailabilityVersion %}
                                        <a href="{{ path('admin_business_version_delete', { id: scheduledAvailabilityVersion.id, returnUrl: app.request.requestUri }) }}" class="btn btn-danger pull-left" onclick="return confirm('Supprimer cette planification ?');">
                                            <i class="fa fa-trash"></i> Supprimer la planification
                                        </a>
                                    {% endif %}
                                    <button type="button" class="btn btn-default" data-dismiss="modal">Fermer</button>
                                </div>
                            </div>
                        </div>
                    </div>
                {% endif %}
                <div class="panel panel-info">
                    <div class="panel-heading">Prix</div>
                    <div class="panel-body">
                        <div id="{{ form.prices.vars.id }}">
                            <ul class="nav nav-tabs">
                                {% for price in form.prices.children | sort((a, b) => a.vars.data.group.position <=> b.vars.data.group.position) %}
                                    {% set scheduledPriceVersion = price.vars.scheduledBusinessVersion|default(null) %}
                                    <li class="{% if loop.first %}active{% endif %}">
                                        <a href="#{{ price.vars.id }}" data-toggle="tab">
                                            {{ price.vars.data.group.name }}
                                            {% if scheduledPriceVersion %}
                                                <span class="label label-warning" style="margin-left: 4px;">
                                                    <i class="fas fa-calendar-alt"></i>
                                                </span>
                                            {% endif %}
                                        </a>
                                    </li>
                                {% endfor %}
                            </ul>
                            <div class="tab-content clearfix">
                                {% for price in form.prices.children | sort((a, b) => a.vars.data.group.position <=> b.vars.data.group.position) %}
                                    {{ form_widget(price) }}
                                {% endfor %}
                            </div>
                        </div>
                    </div>
                </div>
                <div class="panel panel-info">
                    <div class="panel-heading">Images du variant</div>
                    <div class="panel-body">
                        <div class="alert alert-info" role="alert">
                            Si des images sont définies ici, elles remplacent celles du produit sur la fiche boutique.
                        </div>
                        {{ form_row(form.images) }}
                    </div>
                </div>
                <div class="panel panel-info">
                    <div class="panel-heading">Gestion du stock</div>
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-md-4">
                                {{ form_row(form.stockAt) }}
                            </div>
                            <div class="col-md-4">
                                {{ form_row(form.stock) }}
                            </div>
                            <div class="col-md-4">
                                {% if form.vars.data and form.vars.data.stock  %}<strong>Vendu depuis {{ form.stockAt.vars.data|date('d-m-Y H:i')}} : </strong><br/>
                                    {{ (form.vars.data)|saleSinceStockAt }}
                                {% endif %}
                            </div>
                        </div>
                    </div>
                </div>
                <div class="panel panel-info">
                    <div class="panel-heading">Gestion des options</div>
                    <div class="panel-body">
                        <div class="alert alert-info" role="alert">
                            Les images d'une option sélectionnée prennent la priorité sur celles du variant puis du produit.
                        </div>
                        {{ form_row(form.options) }}
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}
{% block product_price_widget %}
    {% set scheduledPriceVersion = form.vars.scheduledBusinessVersion|default(null) %}
    {% set priceGroupName = form.vars.priceGroupName|default(null) %}
    <div class="tab-pane {% if form.vars.data.group.position == '0' %}active{% endif %}" id="{{ form.vars.id }}">
        {{ form_row(form.group) }}

        <div class="row">
            <div class="col-md-5">
                {{ form_row(form.price) }}
            </div>
            <div class="col-md-5">
                {{ form_row(form.priceDiscount) }}
            </div>
            {% if form.scheduledPrice is defined %}
                <div class="col-md-2">
                    <label>&nbsp;</label>
                    <button type="button" class="btn {% if scheduledPriceVersion %}btn-warning{% else %}btn-default{% endif %} btn-block" data-toggle="modal" data-target="#{{ form.vars.id }}_schedule_modal">
                        <i class="fas fa-calendar-alt"></i>
                        {% if scheduledPriceVersion %}Voir{% else %}Planifier{% endif %}
                    </button>
                </div>
            {% endif %}
        </div>
        {% if scheduledPriceVersion %}
            {% set scheduledPrice = scheduledPriceVersion.snapshot.price|default(null) %}
            {% set scheduledPriceDiscount = scheduledPriceVersion.snapshot.priceDiscount|default(null) %}
            <div class="alert alert-warning" style="padding: 8px 10px; margin: 0 0 12px;">
                <strong>Prix planifié</strong>
                le {{ scheduledPriceVersion.validFrom|date('d/m/Y H:i') }}
                - Prix : {{ scheduledPrice is same as(null) ? '-' : (scheduledPrice / 100)|number_format(2, ',', ' ') ~ ' €' }}
                - Remisé : {{ scheduledPriceDiscount is same as(null) ? '-' : (scheduledPriceDiscount / 100)|number_format(2, ',', ' ') ~ ' €' }}
            </div>
        {% endif %}

        {% if form.scheduledPrice is defined %}
            <div class="modal fade" id="{{ form.vars.id }}_schedule_modal" tabindex="-1" role="dialog" aria-labelledby="{{ form.vars.id }}_schedule_modal_title">
                <div class="modal-dialog" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Fermer"><span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title" id="{{ form.vars.id }}_schedule_modal_title">
                                <i class="fas fa-calendar-alt"></i> Planifier un prix futur{% if priceGroupName %} pour {{ priceGroupName }}{% endif %}
                            </h4>
                        </div>
                        <div class="modal-body">
                            {% if scheduledPriceVersion %}
                                <div class="alert alert-warning">
                                    <strong>Planification existante</strong><br>
                                    Publication prévue le {{ scheduledPriceVersion.validFrom|date('d/m/Y H:i:s') }}.<br>
                                    {% set scheduledPrice = scheduledPriceVersion.snapshot.price|default(null) %}
                                    {% set scheduledPriceDiscount = scheduledPriceVersion.snapshot.priceDiscount|default(null) %}
                                    Prix : {{ scheduledPrice is same as(null) ? '-' : (scheduledPrice / 100)|number_format(2, ',', ' ') ~ ' €' }}<br>
                                    Prix remisé : {{ scheduledPriceDiscount is same as(null) ? '-' : (scheduledPriceDiscount / 100)|number_format(2, ',', ' ') ~ ' €' }}
                                </div>
                                {{ form_row(form.scheduledPrice, { attr: { disabled: 'disabled' } }) }}
                                {{ form_row(form.scheduledPriceDiscount, { attr: { disabled: 'disabled' } }) }}
                                {{ form_row(form.scheduledValidFrom, { attr: { disabled: 'disabled' } }) }}
                            {% else %}
                                {{ form_row(form.scheduledPrice) }}
                                {{ form_row(form.scheduledPriceDiscount) }}
                                {{ form_row(form.scheduledValidFrom) }}
                            {% endif %}
                        </div>
                        <div class="modal-footer">
                            {% if scheduledPriceVersion %}
                                <a href="{{ path('admin_business_version_delete', { id: scheduledPriceVersion.id, returnUrl: app.request.requestUri }) }}" class="btn btn-danger pull-left" onclick="return confirm('Supprimer cette planification ?');">
                                    <i class="fa fa-trash"></i> Supprimer la planification
                                </a>
                            {% endif %}
                            <button type="button" class="btn btn-default" data-dismiss="modal">Fermer</button>
                        </div>
                    </div>
                </div>
            </div>
        {% endif %}
    </div>
{% endblock %}
{% block assemblage_widget %}
    <div class="row">
        <div class="col-md-8">
            {{ form_widget(form) }}
        </div>
        <div class="col-md-4 actions">
            <a href="#" class="collection-up btn btn-default"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
            <a href="#" class="collection-down btn btn-default"><i class="fa fa-arrow-down" aria-hidden="true"></i></a>
            <a href="#" class="collection-remove btn btn-default"><i class="fa fa-trash" aria-hidden="true"></i></a>
        </div>
    </div>
{% endblock %}
{% block product_option_widget %}
    <div class="row d-flex">
        <div class="col-md-6">
            {{ form_row(form.translations) }}
        </div>
        <div class="col-md-2">
            {{ form_row(form.multiple) }}
        </div>
        <div class="col-md-4 actions align-middle">
            <a href="#" class="collection-up btn btn-default"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
            <a href="#" class="collection-down btn btn-default"><i class="fa fa-arrow-down" aria-hidden="true"></i></a>
            <a href="#" class="collection-remove btn btn-default"><i class="fa fa-trash" aria-hidden="true"></i></a>
        </div>
    </div>
{% endblock %}
{% block product_variant_option_widget %}
    <div class="panel panel-default">
        <div class="panel-heading">
            {{ form.vars.data and form.vars.data.name ? form.vars.data.name : 'Nouvelle option' }}
        </div>
        <div class="panel-body">
            <div class="row">
                <div class="col-md-4">
                    {{ form_row(form.translations) }}
                </div>
                <div class="col-md-2">
                    {{ form_row(form.price) }}
                    {{ form_row(form.flatFee) }}
                    {{ form_row(form.soldOut) }}
                </div>
                <div class="col-md-4">
                    <label class="control-label">Images de l'option</label>
                    {{ form_row(form.images) }}
                </div>
                <div class="col-md-2 actions">
                    <a href="#" class="collection-up btn btn-default"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
                    <a href="#" class="collection-down btn btn-default"><i class="fa fa-arrow-down" aria-hidden="true"></i></a>
                    <a href="#" class="collection-remove btn btn-default"><i class="fa fa-trash" aria-hidden="true"></i></a>
                    {{ form_widget(form.position) }}
                </div>
            </div>
        </div>
    </div>
{% endblock %}
{% block product_collection_item_widget %}
    <div class="row">
        <div class="col-md-9">
            {{ form_row(form.product) }}
        </div>
        <div class="col-md-3 actions" style="display: flex; align-items: flex-start; gap: 6px;">
            {{ form_widget(form.position, { attr: { class: (form.position.vars.attr.class|default('') ~ ' form-control')|trim, style: 'width: 76px;' } }) }}
            <a href="#" class="collection-up btn btn-default"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
            <a href="#" class="collection-down btn btn-default"><i class="fa fa-arrow-down" aria-hidden="true"></i></a>
            <a href="#" class="collection-remove btn btn-default"><i class="fa fa-trash" aria-hidden="true"></i></a>
        </div>
    </div>
{% endblock %}
{% block shop_config_multiple_widget %}
    <div class="row">
        <div class="col-md-1">
            {{ form_row(form.qtyOf) }}
        </div>
        <div class="col-md-1">
            {{ form_row(form.qtyAt) }}
        </div>
        <div class="col-md-2">
            {{ form_row(form.multiple) }}
        </div>
        <div class="col-md-2">
            {{ form_row(form.minimum) }}
        </div>
        <div class="col-md-2">
            {{ form_row(form.zones) }}
        </div>
        <div class="col-md-2">
            {{ form_row(form.types) }}
        </div>
        <div class="col-md-2 actions">
            <a href="#" class="collection-up btn btn-default"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
            <a href="#" class="collection-down btn btn-default"><i class="fa fa-arrow-down" aria-hidden="true"></i></a>
            <a href="#" class="collection-remove btn btn-default"><i class="fa fa-trash" aria-hidden="true"></i></a>
        </div>
    </div>
{% endblock %}
{% block image_widget %}
    <div class="row">
        <div class="col-md-8">
            <div class="row ">
                <div class="col-sm-12">
                    {% if form.vars.title %}
                        {{ form_row(form.title) }}
                    {% endif %}
                    {{ form_widget(form.file) }}
                </div>
            </div>
            {% if form.vars.data is not null %}
                {% if form.vars.data.path is not null %}
                    <img class="media-file"
                         src="{{ asset(form.vars.data.path) | imagine_filter('relative_widen_100_filter') }}"
                         data-id="{{ form.vars.data.id.__toString }}">
                {% endif %}
            {% endif %}
        </div>
        {% if form.parent.parent is not null %}
            <div class="col-md-4 actions">
                <a href="#" class="collection-up btn btn-default"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
                <a href="#" class="collection-down btn btn-default"><i class="fa fa-arrow-down" aria-hidden="true"></i></a>
                <a href="#" class="collection-remove btn btn-default"><i class="fa fa-trash" aria-hidden="true"></i></a>
            </div>
        {% else %}
            {% if form.vars.data is not null %}
                {% if form.vars.data.path is not null %}
                    <div class="col-md-4 actions">
                        <a href="#" class="remove-media btn btn-default" data-id="{{ form.vars.data.id.__toString }}"><i
                                    class="fa fa-trash" aria-hidden="true"></i></a>
                    </div>
                {% endif %}
            {% endif %}
        {% endif %}

    </div>
{% endblock %}
{% block room_widget %}
    <div class="row">
        <div class="col-md-8">
            <div class="panel panel-info">
                <div class="panel-heading">
                    Texte & Description
                </div>
                <div class="panel-body">
                    {{ form_row(form.translations) }}
                </div>
            </div>
        </div>
        <div class="col-md-4">
            <div class="panel panel-info">
                <div class="panel-heading">
                    Images
                </div>
                <div class="panel-body">
                    {{ form_row(form.images) }}
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-md-12 actions">
            <a href="#" class="collection-up btn btn-default"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
            <a href="#" class="collection-down btn btn-default"><i class="fa fa-arrow-down" aria-hidden="true"></i></a>
            <a href="#" class="collection-remove btn btn-default"><i class="fa fa-trash" aria-hidden="true"></i></a>
        </div>
    </div>

{% endblock %}
{% block trumbowyg_widget %}
    {% set attr = attr|merge({class: (attr.class|default('') ~ ' trumbowyg form-control')|trim}) %}
    {{ block('textarea_widget') }}
{% endblock %}

{% block file_media_widget %}
    <div class="row ">
        <div class="col-md-6">
            {{ form_widget(form.file) }}
        </div>
        <div class="col-md-3">
            {% if form.vars.data is not null %}
                {% if form.vars.data.path is not null %}
                    <a href="{{ asset(form.vars.data.path) | file_path }}" target="_blank"><i
                                class="media-file far fa-file-pdf fa-5x"
                                data-id="{{ form.vars.data.id.__toString }}"></i></a>
                {% endif %}
            {% endif %}
        </div>
        <div class="col-md-3">
            {% if form.vars.data is not null %}
                {% if form.vars.data.path is not null and form.vars.required == false %}
                    <a href="#" class="remove-media btn btn-default" data-id="{{ form.vars.data.id.__toString }}"><i
                                class="fa fa-trash" aria-hidden="true"></i></a>
                {% endif %}
            {% endif %}
        </div>
    </div>
    <div class="row ">
        <div class="col-sm-12">
            {% if form.vars.title %}
                {{ form_row(form.title) }}
            {% endif %}
        </div>
    </div>
{% endblock %}

{% block a2lix_translations_widget %}
    {{ form_errors(form) }}

    <div class="a2lix_translations">
        <ul class="a2lix_translationsLocales nav nav-tabs" role="tablist">
            {% for translationsFields in form %}
                {% set locale = translationsFields.vars.name %}

                <li class="nav-item {% if app.request.locale == locale %}active{% endif %}">
                    <a href="#" class="nav-link {% if app.request.locale == locale %}active{% endif %}"
                       data-toggle="tab"
                       data-target=".{{ translationsFields.vars.id }}_a2lix_translationsFields-{{ locale }}" role="tab"
                       aria-expanded="true">
                        {{ translationsFields.vars.label|default(locale|humanize)|trans }}
                        {% if form.vars.default_locale == locale %}{{ '[Default]'|trans }}{% endif %}
                        {% if translationsFields.vars.required %}*{% endif %}
                    </a>
                </li>
            {% endfor %}
        </ul>

        <div class="a2lix_translationsFields tab-content">
            {% for translationsFields in form %}
                {% set locale = translationsFields.vars.name %}

                <div class="{{ translationsFields.vars.id }}_a2lix_translationsFields-{{ locale }} tab-pane {% if app.request.locale == locale %}active{% endif %} {% if not form.vars.valid %}sonata-ba-field-error{% endif %}"
                     role="tabpanel">
                    {{ form_errors(translationsFields) }}
                    {% if translationsFields.vars.required %}
                        {{ form_widget(translationsFields) }}
                    {% else %}
                        {% for translationField in translationsFields %}
                            {{ form_row(translationField, {'required': false}) }}
                        {% endfor %}
                    {% endif %}
                </div>
            {% endfor %}
        </div>
    </div>
{% endblock %}

{% block a2lix_translationsForms_widget %}
    {{ block('a2lix_translations_widget') }}
{% endblock %}
