open-orchestra/open-orchestra-cms-bundle

View on GitHub
BackofficeBundle/Resources/views/Form/form_div_layout.html.twig

Summary

Maintainability
Test Coverage
{% extends 'BraincraftedBootstrapBundle:Form:bootstrap.html.twig' %}

{% block form %}
    {% spaceless %}
        {% if false == form.vars.valid %}
            <div class="alert alert-danger">
                {{ 'open_orchestra_backoffice.form.global_error'|trans }}
            </div>
        {% endif %}
        {{ form_start(form) }}
        {{ form_widget(form) }}
        {{ form_end(form) }}
    {% endspaceless %}
{% endblock form %}

{% block form_widget %}
    {% set groups  = [] %}
    {% if form.vars.group_enabled is defined and true == form.vars.group_enabled %}
        {% if form.parent is empty %}
            {{ block('global_form_errors') }}
        {% endif %}
        {% set active = -1 %}
        {% for group in form.vars.group %}
            {% set err = false %}
            {% set req = false %}
            {% set group_name = '' %}
            {% set rank = loop.index0 %}
            {% set group_label  = '' %}
            {% set current_group %}
                {% for subgroup in group %}
                    {% set subgroup_html %}
                        {% set group_label = subgroup.group_label %}
                        {% set group_name = subgroup.group_name %}
                        {% for child in subgroup.children %}
                            {{ form_row(form[child]) }}
                            {% set err = err or not form[child].vars.valid %}
                            {% set req = req or (form[child].vars.required is defined and form[child].vars.required) %}
                            {% set active = (active == -1 and err) ? rank : active %}
                        {% endfor %}
                    {% endset %}
                    {% if subgroup.sub_group_label != constant('OpenOrchestra\\Backoffice\\Form\\Type\\Extension\\FormTypeGroupExtension::DEFAULT_SUB_GROUP') %}
                        <fieldset>
                            <legend class="underline-label">{{ subgroup.sub_group_label|trans }}</legend>
                            {{ subgroup_html }}
                        </fieldset>
                    {% else %}
                        {{ subgroup_html }}
                    {% endif %}
                {% endfor %}
            {% endset %}
            {% set groups = groups|merge([{'group_name': group_name,'label': group_label, 'html': current_group, 'err': err, 'req': req}]) %}
        {% endfor %}
        {% set active = (active == -1) ? 0 : active %}
        {% if groups|length == 1 and (groups|first).group_name == constant('OpenOrchestra\\Backoffice\\Form\\Type\\Extension\\FormTypeGroupExtension::DEFAULT_GROUP') %}
            <div class="tab-content">
                {{ (groups|first).html }}
            </div>
        {%  else %}
            <ul role="tablist" class="nav nav-tabs nav-tabs-responsive">
                {% for group in groups %}
                    <li class="{% if active == loop.index0 %}active{% endif %}">
                        <a data-toggle="tab" role="tab" href="#tab-{{ form.vars.name }}-{{ loop.index0 }}" class="{% if group.err %}has-error{% endif %}{% if group.req %} required{% endif %} nav-tab-{{ group.group_name }} ">
                            <span class="text">{{ group.label|default(loop.index0)|trans }}</span>
                        </a>
                    </li>
                {% endfor %}
            </ul>
            <div class="tab-content">
                {% for group in groups %}
                    <div id="tab-{{ form.vars.name }}-{{ loop.index0 }}" class="tab-pane{% if active == loop.index0 %} active{% endif %}{% if group.group_name != '' %} tab-{{ group.group_name }} {% endif %}">
                        {{ group.html }}
                    </div>
                {% endfor %}
            </div>
        {% endif %}
    {% else %}
        {{ parent() }}
    {% endif %}
{% endblock %}

{% block collection_widget %}
    {% spaceless %}
        {% if prototype is defined and prototype.vars.columns is defined %}
            {% set prototype_html %}
                {% set nbrColumn = 0 %}
                {% spaceless %}
                    <tbody data-prototype-id="{{ prototype.vars.name }}">
                    <tr>
                        {% if form.vars.sortable is defined and form.vars.sortable %}
                            <td>
                                {% set nbrColumn = nbrColumn + 1 %}
                                <i class="fa fa-arrows sortable-handler"></i>
                            </td>
                        {% endif %}
                        {% for column in prototype.vars.columns %}
                            <td>
                                {% set nbrColumn = nbrColumn + 1 %}
                                {{ 'open_orchestra_backoffice.form.collection.new_form'|trans }}
                            </td>
                        {% endfor %}
                        <td>
                            {% set nbrColumn = nbrColumn + 1 %}
                            <button type="button" class="btn-nostyle fa fa-pencil btn-sm not open-form hide"></button>
                            <button type="button" class="btn-nostyle fa fa-close btn-sm close-form"></button>
                        </td>
                        {% if form.vars.allow_delete %}
                            <td>
                                {% set nbrColumn = nbrColumn + 1 %}
                                <button type="button" class="btn-nostyle fa fa-trash btn-sm remove-form"></button>
                            </td>
                        {% endif %}
                    </tr>
                    {% set attr = prototype.vars.attr|default([]) %}
                    {% set id = null %}
                    <tr {{ block('widget_container_attributes') }} >
                        <td colspan="{{ nbrColumn }}">
                            <div class="row">
                                {{ form_widget(prototype) }}
                            </div>
                        </td>
                    </tr>
                    </tbody>
                {% endspaceless %}
            {% endset %}
            {% set attr = attr|merge({'data-prototype': prototype_html|e }) %}
            <div class="accordion" {{ block('widget_container_attributes') }}>
                <div class="row">
                    <div class="action">
                        <a href="#" class="btn btn-border close-forms glyphicon glyphicon-minus-sign">{{ 'open_orchestra_backoffice.form.collection.close_forms'|trans }}</a>
                        <a href="#" class="btn btn-border open-forms glyphicon glyphicon-plus-sign">{{ 'open_orchestra_backoffice.form.collection.open_forms'|trans }}</a>
                        {% if form.vars.allow_add %}
                            <a href="#" class="btn btn-border add-form glyphicon glyphicon-plus">{{ form.vars.attr['data-prototype-label-add']|trans }}</a>
                        {% endif %}
                    </div>
                </div>
                <div class="table-responsive">
                    <table class="table table-hide-striped {% if form.vars.attr.class is defined %}{{ form.vars.attr.class }}{% endif %}">
                        <thead {% if form|length == 0 %} class="hide" {% endif %}>
                            <tr>
                                {% if form.vars.sortable is defined and form.vars.sortable %}
                                    <th>
                                        &nbsp;
                                    </th>
                                {% endif %}
                                {% for column in prototype.vars.columns %}
                                    <th>
                                        {{ column.label|trans }}
                                    </th>
                                {% endfor %}
                                <th>&nbsp;</th>
                                {% if form.vars.allow_delete %}
                                    <th>&nbsp;</th>
                                {% endif %}
                            </tr>
                        </thead>
                        {% for field in form %}
                            <tbody class="accordion-form" data-prototype-id="{{ field.vars.name }}">
                                <tr>
                                    {% if form.vars.sortable is defined and form.vars.sortable %}
                                        <td>
                                            <i class="fa fa-arrows sortable-handler"></i>
                                        </td>
                                    {% endif %}
                                    {% for column in field.vars.columns %}
                                        <td>
                                            {{ column.data|trans }}
                                        </td>
                                    {% endfor %}
                                    <td>
                                        <button type="button" class="btn-nostyle fa fa-pencil btn-sm not open-form{% if not field.vars.valid %} hide{% endif %}"></button>
                                        <button type="button" class="btn-nostyle fa fa-close btn-sm close-form{% if field.vars.valid %} hide{% endif %}"></button>
                                    </td>
                                    {% if form.vars.allow_delete %}
                                        <td>
                                            <button type="button" class="btn-nostyle fa fa-trash btn-sm remove-form"></button>
                                        </td>
                                    {% endif %}
                                </tr>
                                <tr class="accordion-formrow {% if field.vars.valid %}hide{% endif %}{% if field.vars.attr.class is defined %} {{ field.vars.attr.class }}{% endif %}">
                                    <td colspan="{{ nbrColumn }}">
                                        <div class="row">
                                            {{ form_widget(field) }}
                                            {{ form_errors(field) }}
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        {% endfor %}
                    </table>
                </div>
            </div>
        {% else %}
            {{ parent() }}
        {% endif %}
    {% endspaceless %}
{% endblock %}

{% block oo_check_list_collection_widget %}
    {% spaceless %}
        {% set collection = form|first %}
        {% set width = form.vars.max_columns > 0 ? (100 / form.vars.max_columns)|number_format(4) ~ '%' : 'auto' %}
        <div class="table-responsive">
            <table class="table table-striped">
                <thead>
                <tr>
                    <th style="width:{{ width }}">&nbsp;</th>
                    {% for rank, cell in form.vars.configuration.row %}
                        <th style="width:{{ width }}">{% if form.vars.configuration.icon[rank] is defined %} <i class="{{ form.vars.configuration.icon[rank] }}"></i>{% endif %}{{ cell }}{% if form.vars.configuration.help[rank] is defined %} <i class="form-help-tooltip icon-prepend fa fa-question-circle-o" data-toggle="tooltip" data-placement="right" data-original-title="{{ form.vars.configuration.help[rank] }}"></i>{% endif %}
                        </th>
                    {% endfor %}
                    <th>&nbsp;</th>
                </tr>
                </thead>
                <tbody>
                {% for name, cell in form.vars.configuration.column %}
                    <tr>
                        <td>{{ cell }}</td>
                        {{ form_widget(collection[name]) }}
                        <td>&nbsp;</td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
        </div>
    {% endspaceless %}
{% endblock oo_check_list_collection_widget %}

{% block oo_check_list_widget %}
    {% set collection = form|first %}
    {% spaceless %}
        {% for child in collection %}
            <td>
                <input type="checkbox" id="{{ child.vars.id }}" name="{{ child.vars.full_name }}" {% if child.vars.value is defined %} value="{{ child.vars.value }}"{% endif %}{% if child.vars.checked %} checked="checked"{% endif %} />
                <label for="{{ child.vars.id }}"></label>
            </td>
        {% endfor %}
    {% endspaceless %}
{% endblock oo_check_list_widget %}

{% block oo_tree_list_collection_widget %}
    {% spaceless %}
        {% set collection = form|first %}
        {% for name, configuration in form.vars.configuration %}
            {% if (collection[name] is defined) %}
                {{ form_widget(collection[name]) }}
            {% endif %}
        {% endfor %}
    {% endspaceless %}
{% endblock oo_tree_list_collection_widget %}

{% block oo_tree_list_widget %}
    {% set collection = form|first %}
    {% spaceless %}
        <fieldset>
            <legend class="underline-label">{{ ('open_orchestra_backoffice.' ~ form.vars.id)|trans }}</legend>
            <div class="perimeter-tree tree tree-form">
                {% for root in form.vars.configuration %}
                    <ul class="children">
                        {{ _self.tabulation(root, collection) }}
                    </ul>
                {% endfor %}
            </div>
        </fieldset>
    {% endspaceless %}
{% endblock oo_tree_list_widget %}

{% macro tabulation(configuration, collection) %}
    {% set key = configuration['root']['path'] %}
    {% set name = configuration['root']['name'] %}
    {% spaceless %}
        <li>
            <div>
                {% if configuration['children'] is defined %}
                    <p class="tree-icon"><i aria-hidden="true" class="fa fa-chevron-down toggle-tree"></i></p>
                {% endif %}

                <input type="checkbox" id="{{ collection[key].vars.id }}" name="{{ collection[key].vars.full_name }}" {% if collection[key].vars.value is defined %} value="{{ collection[key].vars.value }}"{% endif %}{% if collection[key].vars.checked %} checked="checked"{% endif %} />
                <label for="{{ collection[key].vars.id }}">{{ name }}</label>
            </div>
            {% if configuration['children'] is defined %}
                <ul class="children">
                    {% for child in configuration['children'] %}
                        {{ _self.tabulation(child, collection) }}
                    {% endfor %}
                </ul>
            {% endif %}
        </li>
    {% endspaceless %}
{% endmacro %}

{% block oo_check_widget %}
    {% spaceless %}
    {% endspaceless %}
{% endblock oo_check_widget %}

{% block choice_widget %}
    {% spaceless %}
        {% if expanded and multiple %}
            {% set col_size = col_size|default(bootstrap_get_col_size()) %}
            {% set class = 'col-' ~ col_size ~ '-4' %}
            <div {{ block('widget_container_attributes') }} class="form-group {% if form.vars.errors|length > 0 %} has-error{% endif %}">
                {% for child in form %}
                    <div class="{{ class }}">
                        <input type="checkbox" id="{{ child.vars.id }}" name="{{ child.vars.full_name }}" {% if child.vars.value is defined %} value="{{ child.vars.value }}"{% endif %}{% if child.vars.checked %} checked="checked"{% endif %} />
                        <label for="{{ child.vars.id }}">{{ child.vars.label|trans }}</label>
                    </div>
                {% endfor %}
            </div>
        {% else %}
            {{ parent() }}
        {% endif %}
    {% endspaceless %}
{% endblock choice_widget %}

{% block oo_default_listable_checkbox_row %}
    {% spaceless %}
        {% set col_size = col_size|default(bootstrap_get_col_size()) %}
        {% set class = 'col-' ~ col_size ~ '-6' %}
        <div class="{{ class }} default-listable-option">
            {{ form_label(form, null, {label_col: 6}) }}
            {{ form_widget(form, {widget_col: 6}) }}
        </div>
    {% endspaceless %}
{% endblock oo_default_listable_checkbox_row %}

{% block oo_language_by_sites_widget %}
    {% spaceless %}
        <div class="contribution">
            <table class="table table-striped table-language scrollable">
                {% set child = form|first %}
                <thead>
                <tr>
                    <th>&nbsp;</th>
                    {% for choice in child %}
                        <th>
                            {{ choice.vars.label|trans }}
                        </th>
                    {% endfor %}
                </tr>
                </thead>
                <tbody>
                {% for child in form %}
                    <tr>
                        <th>
                            {{ child.vars.label|trans }}
                        </th>
                        {% for choice in child %}
                            <td>
                                <input type="radio" id="{{ choice.vars.full_name }}_{{ choice.vars.value }}" name="{{ choice.vars.full_name }}" value="{{ choice.vars.value }}"{% if choice.vars.checked %} checked=""{% endif %}{% if choice.vars.attr.disabled is defined and choice.vars.attr.disabled == 'disabled' %} disabled="disabled"{% endif %} />
                                <label for="{{ choice.vars.full_name }}_{{ choice.vars.value }}"></label>
                            </td>
                        {% endfor %}
                    </tr>
                {% endfor %}
                </tbody>
            </table>
        </div>
    {% endspaceless %}
{% endblock oo_language_by_sites_widget %}

{% block checkbox_widget %}
    {% spaceless %}
        {% set col_size = col_size|default(bootstrap_get_col_size()) %}
        {% set widget_col = widget_col|default(bootstrap_get_widget_col()) %}
        {% if attr.widget_col is defined and attr.widget_col is not empty %}
            {% set widget_col = attr.widget_col %}
        {% endif %}
        {% if attr.col_size is defined and attr.col_size is not empty %}
            {% set col_size = attr.col_size %}
        {% endif %}
        <div class="col-{{ col_size }}-{{ widget_col }} switch-button">
            <span>{{ 'open_orchestra_backoffice.form.swchoff.off'|trans }}</span>
            <label class="switch">
                {{ parent() }}
                <div class="slider"></div>
            </label>
            <span>{{ 'open_orchestra_backoffice.form.swchoff.on'|trans }}</span>
        </div>
    {% endspaceless %}
{% endblock %}

{% block form_label %}
    {% spaceless %}
        {% set col_size = col_size|default(bootstrap_get_col_size()) %}

        {% if attr.label_col is defined and attr.label_col is not empty %}
            {% set label_col = attr.label_col %}
        {% endif %}
        {% if attr.widget_col is defined and attr.widget_col is not empty %}
            {% set widget_col = attr.widget_col %}
        {% endif %}
        {% if attr.col_size is defined and attr.col_size is not empty %}
            {% set col_size = attr.col_size %}
        {% endif %}

        {% if label is not same as (false) %}
            {% set style = style|default(bootstrap_get_style()) %}
            {% set label_col = label_col|default(bootstrap_get_label_col()) %}

            {% if attr.style is defined and attr.style is not empty %}
                {% set style = attr.style %}
            {% endif %}

            {% set label_attr = label_attr|merge({ 'class': (label_attr.class|default('') ~ ' control-label')|trim }) %}
            {% if style == 'horizontal' %}
                {% set label_attr = label_attr|merge({ 'class': (label_attr.class|default('') ~ ' col-' ~ col_size ~ '-' ~ label_col)|trim }) %}
            {% elseif style == 'inline' %}
                {% set label_attr = label_attr|merge({ 'class': (label_attr.class|default('') ~ ' sr-only')|trim }) %}
            {% endif %}

            {% if not compound %}
                {% set label_attr = label_attr|merge({'for': id}) %}
            {% endif %}
            {% if required %}
                {% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' required')|trim}) %}
            {% endif %}
            {% if label is empty %}
                {% set label = name|humanize %}
            {% endif %}
            <label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
            {{ label|trans({}, translation_domain)|raw }} {{ block('form_help') }}
            </label>
        {% endif %}
    {% endspaceless %}
{% endblock form_label %}

{% block form_row %}
    {% spaceless %}
        {% set style = style|default(bootstrap_get_style()) %}
        {% set col_size = col_size|default(bootstrap_get_col_size()) %}
        {% set widget_col = widget_col|default(bootstrap_get_widget_col()) %}
        {% set label_col = label_col|default(bootstrap_get_label_col()) %}
        {% set form_group_col = form_group_col|default('') %}

        {% if attr.label_col is defined and attr.label_col is not empty %}
            {% set label_col = attr.label_col %}
        {% endif %}
        {% if attr.widget_col is defined and attr.widget_col is not empty %}
            {% set widget_col = attr.widget_col %}
        {% endif %}
        {% if attr.col_size is defined and attr.col_size is not empty %}
            {% set col_size = attr.col_size %}
        {% endif %}
        {% set form_group_class = '' %}
        {% if form_group_col is defined and form_group_col is not empty %}
            {% set form_group_class = 'col-'~col_size~'-'~form_group_col %}
        {% endif %}

        {% if attr.style is defined and attr.style is not empty %}
            {% set style = attr.style %}
        {% endif %}
        {% if label is sameas(false) %}
            {% set widget_col = widget_col + label_col %}
        {% endif %}

        {% if activeErrors is not defined %}
            {% set activeErrors = false %}
            {% if form.vars.errors|length > 0 %}
                {% set activeErrors = true %}
            {% endif %}
            {% for key, field in form %}
                {% if field.vars.errors is defined and field.vars.errors|length > 0 %}
                    {% set activeErrors = true %}
                {% endif %}
            {% endfor %}
        {% endif %}

        <div class="form-group{% if activeErrors %} has-error{% endif %} {{ form_group_class }}">
            {% if style == 'horizontal' %}
                {% if no_label is not defined %}{{ form_label(form) }}{% endif %}
                <div class="col-{{ col_size }}-{{ widget_col }}">
                    {% if form.vars.original_type is defined and form.vars.original_type == 'collection' %}
                        {{ form_errors(form) }}
                        {{ block('form_input_group') }}
                    {% else %}
                        {{ block('form_input_group') }}
                        {{ form_errors(form) }}
                    {% endif %}
                </div>
            {% else %}
                {% if no_label is not defined %}{{ form_label(form) }}{% endif %}
                {{ block('form_input_group') }}
                {{ form_errors(form) }}
            {% endif %}
        </div>

        {% if style == 'inline' %}&nbsp;{% endif %}
    {% endspaceless %}
{% endblock form_row %}

{% block checkbox_row %}
    {{ block('form_row') }}
{% endblock checkbox_row %}

{% block radio_row %}
    {% with {'no_label': true}%}
        {{ block('form_row') }}
    {% endwith %}
{% endblock radio_row %}

{% block radio_widget %}
    {{ parent() }}
    <label for="{{ id }}">{{ form.vars.label }}</label>
{% endblock radio_widget %}

{# Fix choice attr see https://github.com/braincrafted/bootstrap-bundle/pull/379 #}
{% block choice_widget_options %}
    {% spaceless %}
        {% for group_label, choice in options %}
            {% if choice is iterable %}
                <optgroup label="{{ choice_translation_domain is defined ? (choice_translation_domain is same as (false) ? group_label : group_label|trans({}, choice_translation_domain)) : group_label|trans({}, translation_domain) }}">
                    {% set options = choice %}
                    {{ block('choice_widget_options') }}
                </optgroup>
            {% else %}
                {% set id = null %}
                {% set attr = (attribute(choice, 'attr') is defined) ? choice.attr : [] %}
                <option value="{{ choice.value }}"{% if choice is selectedchoice(value) %} selected="selected"{% endif %}{{ block('widget_container_attributes') }}>{{ choice.label|trans({}, translation_domain) }}</option>
            {% endif %}
        {% endfor %}
    {% endspaceless %}
{% endblock choice_widget_options %}

{% block form_help %}
    {% spaceless %}
        {% if attr.help_text is defined and attr.help_text is not empty %}
            {% set help_text = attr.help_text|trans({}, translation_domain)|raw %}
            <i class='form-help-tooltip icon-prepend fa fa-question-circle-o' data-toggle="tooltip" data-placement="bottom" data-original-title="{{ help_text }}"></i>
        {% endif %}
    {% endspaceless %}
{% endblock form_help %}

{% block widget_attributes %}
    {% spaceless %}
        id="{{ id }}" name="{{ full_name }}"{% if read_only %} readonly="readonly"{% endif %}{% if disabled %} disabled="disabled"{% endif %}{% if required %} required="required"{% endif %}{% if max_length %} maxlength="{{ max_length }}"{% endif %}{% if pattern %} pattern="{{ pattern }}"{% endif %}
        {% for attrname, attrvalue in attr %}{% if attrname in ['placeholder', 'title'] %}{{ attrname }}="{{ attrvalue|trans({}, translation_domain) }}" {% elseif attrname in ['input_group'] %}{% else %}{{ attrname }}="{{ attrvalue }}" {% endif %}{% endfor %}
        {% for attrname, attrvalue in label_attr %}{{ attrname }}="{{ attrvalue|trans({}, translation_domain) }}"{% endfor %}
    {% endspaceless %}
{% endblock widget_attributes %}

{% block form_end %}
    {% if form_legend is not defined or form_legend == true %}
        {{ block('form_legend') }}
    {% endif %}
    {% if no_submit_button is not defined or no_submit_button != true %}
        {% spaceless %}
            <div class="bottom-action-buttons">
                {% set break = 0 %}
                {% for block_prefixes in form.vars.block_prefixes|reverse if break == 0 %}
                    {% set blockSubmitWidget = block(block_prefixes ~ '_submit_widget') %}
                    {% if blockSubmitWidget is not empty %}
                        {{ blockSubmitWidget|raw }}
                        {% set break = 1 %}
                    {% endif %}
                {% endfor %}
            </div>
            {{ parent() }}
        {% endspaceless %}
    {% endif %}
{% endblock form_end %}

{% block form_submit_widget %}
    {% spaceless %}
        <div>
            <div class = "btn-group">
                {{ block('save_button') }}

                {% if(form.vars.new_button is defined and true == form.vars.new_button) %}
                    <button type = "button" class = "btn btn-default dropdown-toggle" data-toggle = "dropdown">
                        <span class = "caret"></span>
                        <span class = "sr-only">Toggle Dropdown</span>
                    </button>

                    <ul class="dropdown-menu" role = "menu">
                        <li>{{ block('new_button') }}</li>
                    </ul>
                {% elseif(form.vars.delete_button is defined and true == form.vars.delete_button) %}
                    {{ block('delete_button') }}
                {% endif %}
            </div>
        </div>
    {% endspaceless %}
{% endblock form_submit_widget %}

{% block delete_button %}
    {% set disabled = form.vars.enable_delete_button is defined and not form.vars.enable_delete_button %}
    {% set label = 'open_orchestra_backoffice.form.delete' %}
    {% set attr = {'class': 'delete-button'  ~ (disabled ? ' disabled' : '')} %}
    {% set button_class = 'danger' %}
    {{ block('button_widget') }}
    {% if disabled and form.vars.delete_help_text is defined %}
        <i class='form-help-tooltip icon-prepend fa fa-question-circle-o' data-toggle="tooltip" data-placement="right" data-original-title="{{ form.vars.delete_help_text|trans }}"></i>
    {% endif %}
{% endblock delete_button %}

{% block save_button %}
    {% set label = 'open_orchestra_backoffice.form.submit' %}
    {% set id = 'submit_' ~ form.vars.name %}
    {% set attr = {'class': 'submit-form'} %}
    {% set button_class= 'success' %}
    {{ block('button_widget') }}
{% endblock save_button %}

{# button save and continue #}
{% block new_button %}
    {% set label = 'open_orchestra_backoffice.form.submit_continue' %}
    {% set id = 'submit_' ~ form.vars.name %}
    {% set attr = {'class': 'submit-continue-form'} %}
    {% set button_class= 'success' %}
    {{ block('button_widget') }}
{% endblock new_button %}

{% block form_start %}
    {% spaceless %}
        {{ bootstrap_backup_form_settings() }}
        {% set method = method|upper %}
        {% if method in ["GET", "POST"] %}
            {% set form_method = method %}
        {% else %}
            {% set form_method = "POST" %}
        {% endif %}

        {% if style is defined %}
            {% set attr = attr|merge({ 'class': (attr.class|default('') ~ ' form-' ~ style)|trim }) %}
            {{ bootstrap_set_style(style) }}
        {% endif %}

        {% if form.vars.errors|length > 0 %}
            {% set attr = attr|merge({ 'class': (attr.class|default('') ~ ' has-global-errors')|trim }) %}
        {% endif %}

        {% if col_size is defined %}
            {{ bootstrap_set_col_size(col_size) }}
        {% endif %}

        {% if widget_col is defined %}
            {{ bootstrap_set_widget_col(widget_col) }}
        {% endif %}

        {% if label_col is defined %}
            {{ bootstrap_set_label_col(label_col) }}
        {% endif %}

        {% if simple_col is defined %}
            {{ bootstrap_set_simple_col(simple_col) }}
        {% endif %}

        {% if attr.role is not defined or attr.role is empty %}
            {% set attr = attr|merge({ 'role': 'form' }) %}
        {% endif %}

        <form  name="{{ form.vars.name }}" method="{{ form_method|lower }}" action="{{ action }}"{% for attrname, attrvalue in attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}{% if multipart %} enctype="multipart/form-data"{% endif %} novalidate>
        {% if form_method != method %}
            <input type="hidden" name="_method" value="{{ method }}" />
        {% endif %}
    {% endspaceless %}
{% endblock form_start %}

{% block oo_date_picker_widget %}
    {% spaceless %}
        {% if form.vars.widget == 'single_text' %}
            <div class="input-group">
            {% set attr = attr|merge({ 'class': (attr.class|default('') ~ ' datepicker')|trim, 'data-dateformat': form.vars.format|default('yyyy-mm-dd')|lower }) %}
        {% endif %}
        {{ block('date_widget') }}
        {% if form.vars.widget == 'single_text' %}
            </div>
        {% endif %}
    {% endspaceless %}
{% endblock oo_date_picker_widget %}

{% block form_legend %}
    <div class="help-block">
        <p>* {{ 'open_orchestra_backoffice.form.orchestra_fields.required_field' | trans }}</p>
        {% if form_legend_helper is defined and form_legend_helper is not empty %}
            <p>** {{ form_legend_helper | trans }}</p>
        {% endif %}
    </div>
{% endblock form_legend %}

{% block oo_multi_languages_row %}
    {# Disabled display error on form row. There are added in oo_multi_languages_widget #}
    {% set activeErrors = false %}
    {{ block('form_row') }}
{% endblock oo_multi_languages_row %}

{% block oo_multi_languages_widget %}
    {% spaceless %}
        <div {{ block('widget_container_attributes') }}>
            <ul class="nav nav-tabs multi-languages " role="tablist" id="myTab">
                {% set activeKey = -1 %}
                {% set firstKey = -1 %}
                {% for key, field in form %}
                    {% if -1 == firstKey %}
                        {% set firstKey = key %}
                    {% endif %}
                    {% if -1 == activeKey and field.vars.errors|length > 0 %}
                        {% set activeKey = key %}
                    {% endif %}
                {% endfor %}
                {% if -1 == activeKey %}
                    {% set activeKey = firstKey %}
                {% endif %}
                {% for key, field in form %}
                    <li class="{% if key == activeKey %} active {% endif %} {% if field.vars.errors|length > 0 %} has-error {% endif %} ">
                        <a href="#tab-{{ form.vars.id }}-{{ key }}" role="tab" data-toggle="tab">
                            <img
                                    src="/images/languages/{{ key }}.png"
                                    alt="{{ ('open_orchestra_backoffice.language.' ~ key)|trans }}"
                            >
                            {{ form_label(field) }}
                        </a>
                    </li>
                {% endfor %}
            </ul>
            <div class="tab-content">
                {% for key, field in form %}
                    <div class="tab-pane {% if key == activeKey %} active {% endif %}" id="tab-{{ form.vars.id }}-{{ key }}">
                        <div class="form-group{% if field.vars.errors|length > 0 %} has-error{% endif %}">
                            {{ form_widget(field) }}
                            {{ form_rest(field) }}
                            {{ form_errors(field) }}
                        </div>
                    </div>
                {% endfor %}
            </div>
        </div>
    {% endspaceless %}
{% endblock oo_multi_languages_widget %}

{% block _oo_redirection_type_widget %}
    {% spaceless %}
        <div class="col-md-8">
            {% for option in form.children %}
                <div class="radio radio-inline">
                    <input
                            type="radio"
                            value="{{ option.vars.value }}"
                            name="{{ option.vars.full_name }}"
                            id="{{ option.vars.id }}"
                            {% if (option.vars.checked) %}checked="checked"{% endif %}
                    >
                    <label for="{{ option.vars.id }}">{{ option.vars.label|trans }}</label>
                </div>
            {% endfor %}
        </div>
    {% endspaceless %}
{% endblock _oo_redirection_type_widget %}

{% block choice_widget_collapsed %}
    {% spaceless %}
        {% set attr = attr|merge({ 'class': (attr.class|default('') ~ ' form-control')|trim }) %}

        <div class="styled-select {% if multiple %} multiple{% endif %}">
            <select {{ block('widget_attributes') }}{% if multiple %} multiple="multiple"{% endif %}>
                {% if empty_value is not none %}
                    <option {% if required %} disabled="disabled"{% if value is empty %} selected="selected"{% endif %}{% endif %} value="">{{ empty_value|trans({}, translation_domain) }}</option>
                {% endif %}
                {% if preferred_choices|length > 0 %}
                    {% set options = preferred_choices %}
                    {{ block('choice_widget_options') }}
                    {% if choices|length > 0 and separator is not none %}
                        <option disabled="disabled">{{ separator }}</option>
                    {% endif %}
                {% endif %}
                {% set options = choices %}
                {{ block('choice_widget_options') }}
            </select>
        </div>

    {% endspaceless %}
{% endblock choice_widget_collapsed %}

{% block file_widget %}
    {% spaceless %}
        {% set col_size = col_size|default(bootstrap_get_col_size()) %}

        {% if attr.simple_col is defined and attr.simple_col is not empty %}
            {% set simple_col = attr.simple_col %}
        {% endif  %}

        {% if attr.col_size is defined and attr.col_size is not empty %}
            {% set col_size = attr.col_size %}
        {% endif %}

        <div class="oo-input-file{% if simple_col is defined %} col-{{ col_size }}-{{ simple_col }} {% endif %}">
            <label class="btn btn-border">
                {{ 'open_orchestra_backoffice.form.file.choose'|trans }} ...
                <input type="file" class="sr-only" {{ block('widget_attributes') }} multiple>
            </label >
            <span class="upload-file-info"></span>
        </div>
    {% endspaceless %}
{% endblock file_widget %}