{# This file is part of the Sonata package. (c) Thomas Rabaix For the full copyright and license information, please view the LICENSE file that was distributed with this source code. #} {% extends 'form_div_layout.html.twig' %} {% block form_errors -%} {% if errors|length > 0 %} {% if not form.parent %}
{% endif %} {% if not form.parent %}
{% endif %} {% endif %} {%- endblock form_errors %} {% block sonata_help %} {% spaceless %} {% if sonata_help is defined and sonata_help %} {{ sonata_help|raw }} {% endif %} {% endspaceless %} {% endblock %} {% block form_widget -%} {{ parent() }} {{ block('sonata_help') }} {%- endblock form_widget %} {% block form_widget_simple %} {% set type = type|default('text') %} {% if type != 'file' %} {% set attr = attr|merge({'class': attr.class|default('') ~ ' form-control'}) %} {% endif %} {{ parent() }} {% endblock form_widget_simple %} {% block textarea_widget %} {% set attr = attr|merge({'class': attr.class|default('') ~ ' form-control'}) %} {{ parent() }} {% endblock textarea_widget %} {% block money_widget -%} {% if money_pattern == '{{ widget }}' %} {{- block('form_widget_simple') -}} {% else %} {% set currencySymbol = money_pattern|replace({'{{ widget }}': ''})|trim %} {% if money_pattern matches '/^{{ widget }}/' %}
{{- block('form_widget_simple') -}} {{ currencySymbol }}
{% elseif money_pattern matches '/{{ widget }}$/' %}
{{ currencySymbol }} {{- block('form_widget_simple') -}}
{% endif %} {% endif %} {%- endblock money_widget %} {% block percent_widget %} {% spaceless %} {% set type = type|default('text') %}
{{ block('form_widget_simple') }} %
{% endspaceless %} {% endblock percent_widget %} {% block checkbox_widget -%} {% set parent_label_class = parent_label_class|default('') -%} {% if 'checkbox-inline' in parent_label_class %} {{- form_label(form, null, { widget: parent() }) -}} {% else -%}
{{- form_label(form, null, { widget: parent() }) -}}
{%- endif %} {%- endblock checkbox_widget %} {% block radio_widget -%} {%- set parent_label_class = parent_label_class|default('') -%} {% if 'radio-inline' in parent_label_class %} {{- form_label(form, null, { widget: parent() }) -}} {% else -%}
{{- form_label(form, null, { widget: parent() }) -}}
{%- endif %} {%- endblock radio_widget %} {# Labels #} {% block form_label %} {% spaceless %} {% if label is not same as(false) and sonata_admin.options['form_type'] == 'horizontal' %} {% set label_class = 'col-sm-3' %} {% endif %} {% set label_class = label_class|default('') ~ ' control-label' %} {% if label is not same as(false) %} {% set label_attr = label_attr|merge({'class': label_attr.class|default('') ~ label_class }) %} {% 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 %} {%- if label_format is defined and label_format is not empty -%} {% set label = label_format|replace({ '%name%': name, '%id%': id, }) %} {%- else -%} {% set label = name|humanize %} {%- endif -%} {% endif %} {% if translation_domain is same as(false) %} {{- label -}} {% elseif not sonata_admin.admin %} {{- label|trans({}, translation_domain) -}} {% else %} {{ label|trans({}, sonata_admin.field_description.translationDomain ?: admin.translationDomain) }} {% endif %} {% endif %} {% endspaceless %} {% endblock form_label %} {% block checkbox_label -%} {{- block('checkbox_radio_label') -}} {%- endblock checkbox_label %} {% block radio_label -%} {{- block('checkbox_radio_label') -}} {%- endblock radio_label %} {% block checkbox_radio_label %} {% if sonata_admin.admin %} {% set translation_domain = sonata_admin.field_description.translationDomain %} {% endif %} {# Do not display the label if widget is not defined in order to prevent double label rendering #} {% if widget is defined %} {% if required %} {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) %} {% endif %} {% if parent_label_class is defined %} {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ parent_label_class)|trim}) %} {% endif %} {% if label is not same as(false) and label is empty %} {% set label = name|humanize %} {% endif %} {{- widget|raw -}} {%- if label is not same as(false) -%} {{- label|trans({}, translation_domain) -}} {%- endif -%} {% endif %} {% endblock checkbox_radio_label %} {% block choice_widget_expanded %} {% spaceless %} {% set attr = attr|merge({'class': attr.class|default('') ~ ' list-unstyled'}) %}
    {% for child in form %}
  • {{ form_widget(child, {'horizontal': false, 'horizontal_input_wrapper_class': ''}) }} {# {'horizontal': false, 'horizontal_input_wrapper_class': ''} needed to avoid MopaBootstrapBundle messing with the DOM #}
  • {% endfor %}
{% endspaceless %} {% endblock choice_widget_expanded %} {% block choice_widget_collapsed %} {% spaceless %} {% if required and placeholder is defined and placeholder is none %} {% set required = false %} {% elseif required and empty_value is defined and empty_value_in_choices is defined and empty_value is none and not empty_value_in_choices and not multiple %} {% set required = false %} {% endif %} {% set attr = attr|merge({'class': attr.class|default('') ~ ' form-control'}) %} {% if (sortable is defined) and sortable and multiple %} {{ block('sonata_type_choice_multiple_sortable') }} {% else %} {% endif %} {% endspaceless %} {% endblock choice_widget_collapsed %} {% block date_widget %} {% spaceless %} {% if widget == 'single_text' %} {{ block('form_widget_simple') }} {% else %} {% if row is not defined or row == true %} {% set attr = attr|merge({'class': attr.class|default('') ~ ' row' }) %} {% endif %} {% set input_wrapper_class = input_wrapper_class|default('col-sm-4') %}
{{ date_pattern|replace({ '{{ year }}': '
' ~ form_widget(form.year) ~ '
', '{{ month }}': '
' ~ form_widget(form.month) ~ '
', '{{ day }}': '
' ~ form_widget(form.day) ~ '
', })|raw }}
{% endif %} {% endspaceless %} {% endblock date_widget %} {% block time_widget %} {% spaceless %} {% if widget == 'single_text' %} {{ block('form_widget_simple') }} {% else %} {% if row is not defined or row == true %} {% set attr = attr|merge({'class': attr.class|default('') ~ ' row' }) %} {% endif %} {% set input_wrapper_class = input_wrapper_class|default('col-sm-6') %}
{{ form_widget(form.hour) }}
{% if with_minutes %}
{{ form_widget(form.minute) }}
{% endif %} {% if with_seconds %}
{{ form_widget(form.second) }}
{% endif %}
{% 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('') ~ ' row' }) %}
{{ form_errors(form.date) }} {{ form_errors(form.time) }} {% if form.date.vars.widget == 'single_text' %}
{{ form_widget(form.date) }}
{% else %} {{ form_widget(form.date, {'row': false, 'input_wrapper_class': 'col-sm-2'}) }} {% endif %} {% if form.time.vars.widget == 'single_text' %}
{{ form_widget(form.time) }}
{% else %} {{ form_widget(form.time, {'row': false, 'input_wrapper_class': 'col-sm-2'}) }} {% endif %}
{% endif %} {% endspaceless %} {% endblock datetime_widget %} {% block form_row %} {% set show_label = show_label|default(true) %}
{% if sonata_admin.field_description.options is defined %} {% set label = sonata_admin.field_description.options.name|default(label) %} {% endif %} {% set div_class = 'sonata-ba-field' %} {% if label is same as(false) %} {% set div_class = div_class ~ ' sonata-collection-row-without-label' %} {% endif %} {% if sonata_admin is defined and sonata_admin.options['form_type'] == 'horizontal' %} {# Add an offset if no label or is a checkbox/radio #} {% if label is same as(false) or form.vars.checked is defined %} {% if 'collection' in form.parent.vars.block_prefixes %} {% set div_class = div_class ~ ' col-sm-12' %} {% else %} {% set div_class = div_class ~ ' col-sm-9 col-sm-offset-3' %} {% endif %} {% else %} {% set div_class = div_class ~ ' col-sm-9' %} {% endif %} {% endif %} {% if show_label %} {{ form_label(form, label|default(null)) }} {% endif %} {% if sonata_admin is defined and sonata_admin_enabled %} {% set div_class = div_class ~ ' sonata-ba-field-' ~ sonata_admin.edit ~ '-' ~ sonata_admin.inline %} {% endif %} {% if errors|length > 0 %} {% set div_class = div_class ~ ' sonata-ba-field-error' %} {% endif %}
{{ form_widget(form, {'horizontal': false, 'horizontal_input_wrapper_class': ''}) }} {# {'horizontal': false, 'horizontal_input_wrapper_class': ''} needed to avoid MopaBootstrapBundle messing with the DOM #} {% if errors|length > 0 %}
{{ form_errors(form) }}
{% endif %} {% if sonata_admin is defined and sonata_admin_enabled and sonata_admin.field_description.help|default(false) %} {{ sonata_admin.field_description.help|trans({}, sonata_admin.field_description.translationDomain ?: admin.translationDomain)|raw }} {% endif %}
{% endblock form_row %} {% block checkbox_row -%} {% set show_label = false %} {{ block('form_row') }} {%- endblock checkbox_row %} {% block radio_row -%} {% set show_label = false %} {{ block('form_row') }} {%- endblock radio_row %} {% block sonata_type_native_collection_widget_row %} {% spaceless %}
{% if allow_delete %}
{% endif %} {{ form_row(child, { label: false }) }} {% if allow_delete %}
{% endif %}
{% endspaceless %} {% endblock sonata_type_native_collection_widget_row %} {% block sonata_type_native_collection_widget %} {% spaceless %} {% if prototype is defined %} {% set child = prototype %} {% set allow_delete_backup = allow_delete %} {% set allow_delete = true %} {% set attr = attr|merge({'data-prototype': block('sonata_type_native_collection_widget_row'), 'data-prototype-name': prototype.vars.name, 'class': attr.class|default('') }) %} {% set allow_delete = allow_delete_backup %} {% endif %}
{{ form_errors(form) }} {% for child in form %} {{ block('sonata_type_native_collection_widget_row') }} {% endfor %} {{ form_rest(form) }} {% if allow_add %}
{% endif %}
{% endspaceless %} {% endblock sonata_type_native_collection_widget %} {% block sonata_type_immutable_array_widget %} {% spaceless %}
{{ form_errors(form) }} {% for key, child in form %} {{ block('sonata_type_immutable_array_widget_row') }} {% endfor %} {{ form_rest(form) }}
{% endspaceless %} {% endblock sonata_type_immutable_array_widget %} {% block sonata_type_immutable_array_widget_row %} {% spaceless %}
{{ form_label(child) }} {% set div_class = "" %} {% if sonata_admin.options['form_type'] == 'horizontal' %} {% set div_class = 'col-sm-9' %} {% endif%}
{{ form_widget(child, {'horizontal': false, 'horizontal_input_wrapper_class': ''}) }} {# {'horizontal': false, 'horizontal_input_wrapper_class': ''} needed to avoid MopaBootstrapBundle messing with the DOM #}
{% if child.vars.errors|length > 0 %}
{{ form_errors(child) }}
{% endif %}
{% endspaceless %} {% endblock %} {% block sonata_type_model_autocomplete_widget %} {% include template %} {% endblock sonata_type_model_autocomplete_widget %} {% block sonata_type_choice_field_mask_widget %} {{ block('choice_widget') }} {% set main_form_name = id|slice(0, id|length - name|length) %} {% endblock %} {% block sonata_type_choice_multiple_sortable %} {% endblock %}