{% extends 'form_div_layout.html.twig' %} {% from 'MopaBootstrapBundle::flash.html.twig' import flash %} {# Buttons #} {% block button_attributes %} {% set attr = attr|merge({class: 'btn ' ~ attr.class | default("")}) %} {{ parent() }} {% endblock button_attributes %} {% block button_widget %} {% spaceless %} {% if label is empty %} {% set label = name|humanize %} {% endif %} {% endspaceless %} {% endblock button_widget %} {# Widgets #} {% block form_widget_simple %} {% spaceless %} {% set type = type|default('text') %} {% if type != 'hidden' and widget_addon.type|default(null) is not null %}
{% if widget_addon.type == 'prepend' %} {{ block('widget_addon') }} {% endif %} {% endif %} {% if not widget_remove_btn|default(null) %} {% set attr = attr|merge({'class': attr.class|default('') ~ ' not-removable'}) %} {% endif %} {% if type != 'hidden' and widget_addon.type|default(null) is not null %} {% if widget_addon.type == 'append' %} {{ block('widget_addon') }} {% endif %}
{% endif %} {% endspaceless %} {% endblock form_widget_simple %} {% block form_widget_compound %} {% spaceless %} {% if form.parent == null %} {% if render_fieldset %}
{% endif %} {% if show_legend %}{{ block('form_legend') }}{% endif %} {% endif %} {{ block('form_rows_visible') }} {{ form_rest(form) }} {% if form.parent == null %} {% if render_fieldset %}
{% endif %} {% endif %} {% endspaceless %} {% endblock form_widget_compound %} {% block collection_widget %} {% spaceless %} {{ block('form_widget') }} {% endspaceless %} {% endblock collection_widget %} {% block choice_widget_expanded %} {% spaceless %} {% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' ' ~ (multiple ? 'checkbox' : 'radio'))}) %} {% set label_attr = label_attr|merge({'class': (label_attr.class ~ ' ' ~ (widget_type ? widget_type : ''))}) %} {% set label_attr = label_attr|merge({'class': (label_attr.class ~ ' ' ~ (inline is defined and inline ? 'inline' : ''))|trim}) %}
{% for child in form %} {{ form_widget(child, {'attr': {'class': attr.widget_class|default('')}}) }} {{ child.vars.label|trans({}, translation_domain) }} {% endfor %}
{% endspaceless %} {% endblock choice_widget_expanded %} {% block choice_widget_collapsed %} {% spaceless %} {% if widget_addon.type == 'prepend' %} {{ block('widget_addon') }} {% endif %} {% if widget_addon.type == 'append' %} {{ block('widget_addon') }} {% endif %} {% endspaceless %} {% endblock choice_widget_collapsed %} {% block checkbox_widget %} {% spaceless %} {% if label is not sameas(false) and label is empty %} {% set label = name|humanize %} {% endif %} {% if form.parent != null and 'choice' not in form.parent.vars.block_prefixes and label_render %} {% endif %} {% endif %} {% endspaceless %} {% endblock checkbox_widget %} {% block date_widget %} {% spaceless %} {% if widget == 'single_text' %} {% if datepicker is defined %}
{% if widget_addon.type == 'prepend' %} {{ block('widget_addon') }} {% endif %} {% set attr = attr|merge({'class': attr.class|default('') ~ ' not-removable grd-white'}) %} {% if widget_addon.type == 'append' %} {{ block('widget_addon') }} {% endif %}
{% else %} {{ block('form_widget_simple') }} {% endif %} {% else %} {% set attrYear = attr|merge({'class': attr.class|default('inline') ~ ' input-small'}) %} {% set attrMonth = attr|merge({'class': attr.class|default('inline') ~ ' input-mini'}) %} {% set attrDay = attr|merge({'class': attr.class|default('inline') ~ ' input-mini'}) %} {{ date_pattern|replace({ '{{ year }}': form_widget(form.year, {'attr': attrYear}), '{{ month }}': form_widget(form.month, {'attr': attrMonth}), '{{ day }}': form_widget(form.day, {'attr': attrDay}), })|raw }} {{ block('help') }} {% endif %} {% endspaceless %} {% endblock date_widget %} {% block time_widget %} {% spaceless %} {% if widget == 'single_text' %} {{ block('form_widget_simple') }} {% else %} {% set attr = attr|merge({'class': attr.class|default('inline')}) %}
{{ form_widget(form.hour, { 'attr': { 'size': '1', 'class': 'input-mini' } }) }}{% if with_minutes %}:{{ form_widget(form.minute, { 'attr': { 'size': '1', 'class': 'input-mini' } }) }}{% endif %}{% if with_seconds %}:{{ form_widget(form.second, { 'attr': { 'size': '1', 'class': 'input-mini' } }) }}{% endif %}
{{ block('help') }} {% endif %} {% endspaceless %} {% endblock time_widget %} {% block datetime_widget %} {% spaceless %} {% if widget == 'single_text' %} {{ block('form_widget_simple') }} {% else %} {% set attr = attr|merge({'class': attr.class|default('')}) %}
{{ form_errors(form.date) }} {{ form_errors(form.time) }} {{ form_widget(form.date, {'attr': {'class': attr.widget_class|default('')}}) }} {{ form_widget(form.time, {'attr': {'class': attr.widget_class|default('')}}) }}
{% endif %} {% endspaceless %} {% endblock datetime_widget %} {% block percent_widget %} {% spaceless %} {% set widget_addon = widget_addon|merge({'text': widget_addon.text|default('%')}) %} {{ block('form_widget_simple') }} {% endspaceless %} {% endblock percent_widget %} {% block money_widget %} {% spaceless %} {% set widget_addon = widget_addon|merge({'text': money_pattern|replace({ '{{ widget }}': ''})}) %} {{ block('form_widget_simple') }} {% endspaceless %} {% endblock money_widget %} {# Labels #} {% block form_legend %} {% spaceless %} {% if label is empty %} {% set label = name|humanize %} {% endif %} {{ label|trans({}, translation_domain) }} {% if widget_add_btn %} {{ block('form_widget_add_btn') }} {% endif %} {% endspaceless %} {% endblock form_legend %} {% block form_label %} {% if 'checkbox' not in block_prefixes or widget_checkbox_label in ['label', 'both'] %} {% spaceless %} {% if label is not sameas(false) %} {% if label is empty %} {% set label = name|humanize %} {% endif %} {% if not compound %} {% set label_attr = label_attr|merge({'for': id}) %} {% endif %} {% set label_attr = label_attr|merge({'class': label_attr.class|default('') ~ ' control-label' ~ (required ? ' required' : ' optional') }) %} {{ label|trans({}, translation_domain) }} {{ block('label_asterisk') }} {% if widget_add_btn %} {{ block('form_widget_add_btn') }} {% endif %} {% if help_label_tooltip_title %} {{ block('help_label_tooltip') }} {% endif %} {% if help_label_popover_title %} {{ block('help_label_popover') }} {% endif %} {% if help_label %} {{ block('help_label') }} {% endif %} {% endif %} {% endspaceless %} {% endif %} {% endblock form_label %} {% block help_label %}

{{ help_label|trans({}, translation_domain) }}

{% endblock help_label %} {% block help_label_tooltip %}

{% endblock help_label_tooltip %} {% block help_label_popover %}

{% endblock help_label_popover %} {# Rows #} {% block form_rows_visible %} {% spaceless %} {% for child in form %} {% if 'hidden' not in child.vars.block_prefixes %} {% if 'collection' in form.vars.block_prefixes and not omit_collection_item %}
{% endif %} {{ form_row(child) }} {% if 'collection' in form.vars.block_prefixes and not omit_collection_item %}
{% endif %} {% endif %} {% endfor %} {% endspaceless %} {% endblock form_rows_visible %} {% block form_row %} {% spaceless %} {% set attr = attr|merge({'class': attr.class|default('') ~ (errors|length > 0 ? ' error' : '') }) %} {{ block('widget_control_group_start') }} {{ widget_prefix|trans({}, translation_domain)|raw }} {{ form_widget(form, _context) }} {{ widget_suffix|trans({}, translation_domain)|raw }} {% if widget_remove_btn is defined %} {{ block('form_widget_remove_btn') }} {% endif -%} {{ block('form_message') }} {{ block('widget_control_group_end') }} {% endspaceless %} {% endblock form_row %} {# Support #} {% block form_message %} {% spaceless %} {{ form_errors(form) }} {{ block('form_help') }} {% endspaceless %} {% endblock form_message %} {# Help #} {% block form_help %} {% spaceless %} {% if 'checkbox' not in form.vars.block_prefixes %}{# checkbox widget/choice widget problem see https://github.com/phiamo/MopaBootstrapBundle/commit/67406a16b38e5b622fffdd5b9c8a8707ca73f493#commitcomment-1295951 # #} {% if help_inline %}

{{ help_inline|trans({}, translation_domain)|raw }}

{%endif %} {% endif %} {% if help_block %}

{{ help_block|trans({}, translation_domain)|raw }}

{%endif %} {% endspaceless %} {% endblock form_help %} {% block form_widget_add_btn %} {% spaceless %} {% if widget_add_btn %} {% set button_type = 'add' %} {% set button_values = widget_add_btn %} {{ block('collection_button') }} {% endif %} {% endspaceless %} {% endblock form_widget_add_btn %} {% block form_widget_remove_btn %} {% spaceless %} {% if widget_remove_btn %} {% set button_type = 'remove' %} {% set button_values = widget_remove_btn %} {{ block('collection_button') }} {% endif %} {% endspaceless %} {% endblock form_widget_remove_btn %} {% block collection_button %} {% if button_values.icon is defined %} {% endif %} {{ button_values.label|trans({}, translation_domain) }} {% endblock collection_button %} {% block label_asterisk %} {% if required %} {% if render_required_asterisk %}*{% endif %} {% else %} {% if render_optional_text %}{{ "(optional)"|trans({}, translation_domain) }}{% endif %} {% endif %} {% endblock label_asterisk %} {% block widget_addon %} {% spaceless %} {# prevent deep nesting wrong context copy error #} {% from 'MopaBootstrapBundle::icons.html.twig' import icon %} {{ (widget_addon.text|default(false) ? widget_addon.text|trans({}, translation_domain) : icon(widget_addon.icon))|raw('html') }} {{ (widget_addon.html|default(false) ? widget_addon.html|raw('html') : '') }} {% endspaceless %} {% endblock widget_addon %} {# Errors #} {% block _form_errors %} {% spaceless %} {% if errors|length > 0 %} {% endif %} {% endspaceless %} {% endblock _form_errors %} {% block form_errors %} {% spaceless %} {% if errors_on_forms and form.parent == null %} {# prevent deep nesting wrong context copy error #} {% from 'MopaBootstrapBundle::flash.html.twig' import flash %} {% for error in errors %} {{ flash( 'error', error.messagePluralization is null ? error.messageTemplate|trans(error.messageParameters, 'validators') : error.messageTemplate|transchoice(error.messagePluralization, error.messageParameters, 'validators') ) }} {% endfor %} {% elseif error_delay %} {% for child in form %} {% if loop.index == 1 %} {% if child.set('errors', errors) %}{% endif %} {% endif %} {% endfor %} {% else %} {% if errors|length > 0 %} {% for error in errors %} {{ error.messagePluralization is null ? error.messageTemplate|trans(error.messageParameters, 'validators') : error.messageTemplate|transchoice(error.messagePluralization, error.messageParameters, 'validators') }}
{% endfor %}
{% endif %} {% endif %} {% endspaceless %} {% endblock form_errors %} {# used to determine which type of error #} {% block error_type %} {% spaceless %} {% if error_type %} {{ error_type }} {% elseif form.parent == null %} {{ form.vars.error_type | default('inline') }} {% else %} inline {% endif %} {% endspaceless %} {% endblock error_type %} {# widget helper blocks #} {% block widget_control_group_start %} {% spaceless %} {% if widget_control_group|default(false) or form.parent == null %} {% if prototype is defined %} {% set data_prototype = 'collection' in form.vars.block_prefixes and not omit_collection_item ? '
' ~ form_row(prototype) ~ '
' : form_row(prototype) %} {% set data_prototype_name = form.vars.form.vars.prototype.vars.name|default('__name__') %} {% set widget_control_group_attr = widget_control_group_attr|merge({'data-prototype': data_prototype, 'data-prototype-name': data_prototype_name, 'data-widget-controls': widget_controls|default(false) ? 'true' : 'false'})|merge(attr) %} {% endif %} {% set widget_control_group_attr = widget_control_group_attr|merge({'id': id ~ '_control_group', 'class': widget_control_group_attr.class|default('') ~ ' control-group'}) %} {% if errors|length > 0 %} {% set widget_control_group_attr = widget_control_group_attr|merge({'class': widget_control_group_attr.class|default('') ~ ' error'}) %} {% endif %} {% if 'collection' in form.vars.block_prefixes and attr.class is defined %} {% set widget_control_group_attr = widget_control_group_attr|merge({'class': widget_control_group_attr.class|default('') ~ ' ' ~ attr.class}) %} {% endif %}
{# a form item containing the field in block_prefixes is a near subform or a field directly #} {% if (form|length > 0 and form.parent != null) and 'field' not in form.vars.block_prefixes %} {% if show_child_legend%} {{ block('form_legend') }} {% elseif label_render %} {{ form_label(form, label|default(null)) }} {% endif %} {% else %} {% if label_render %} {{ form_label(form, label|default(null)) }} {% endif %} {% endif %} {% if widget_controls|default(false) or form.parent == null %} {% set widget_controls_attr = widget_controls_attr|merge({'class': widget_controls_attr.class|default('') ~ ' controls'}) %}
{% endif %} {% else %} {% if label_render %} {{ form_label(form, label|default(null)) }} {% endif %} {% endif %} {% endspaceless %} {% endblock widget_control_group_start %} {% block widget_control_group_end %} {% spaceless %} {% if widget_control_group|default(false) or form.parent == null %} {% if widget_controls|default(false) or form.parent == null %}
{% endif %}
{% endif %} {% endspaceless %} {% endblock widget_control_group_end %}