{# 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 form_help -%} {% if sonata_admin_translation_domain is defined and translation_domain is null %} {% set translation_domain = sonata_admin_translation_domain %} {% endif %} {% if help is not empty %} {% set help_attr = help_attr|merge({class: (help_attr.class|default('') ~ ' help-block sonata-ba-field-help')}) %} {{ parent() }} {% endif %} {%- endblock form_help %} {% 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 %} {% apply spaceless %} {% set type = type|default('text') %}
{{ block('form_widget_simple') }} %
{% endapply %} {% 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 %} {% apply 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(label_translation_parameters, translation_domain) -}} {%- else -%} {{- label|trans(label_translation_parameters, sonata_admin.field_description.translationDomain|default(sonata_admin.admin.translationDomain)) -}} {%- endif -%} {% endif %} {% endapply %} {% 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) -%} {% if translation_domain is same as(false) %} {{- label -}} {% else %} {{- label|trans(label_translation_parameters, translation_domain) -}} {%- endif -%} {%- endif -%} {% endif %} {% endblock checkbox_radio_label %} {% block choice_widget_expanded %} {% apply spaceless %} {% set attr = attr|merge({'class': attr.class|default('') ~ ' list-unstyled'}) %}
    {% for child in form %}
  • {{ form_widget(child, { 'horizontal': false, 'horizontal_input_wrapper_class': '', 'translation_domain': choice_translation_domain }) }} {# 'horizontal' values are needed to avoid MopaBootstrapBundle messing with the DOM #}
  • {% endfor %}
{% endapply %} {% endblock choice_widget_expanded %} {% block choice_widget_collapsed %} {% apply 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 %} {% set data_placeholder = placeholder %} {% if placeholder != '' %} {% if not sonata_admin.admin %} {% set data_placeholder = placeholder|trans({}, translation_domain) %} {% else %} {% set data_placeholder = placeholder|trans({}, sonata_admin.field_description.translationDomain) %} {% endif %} {% endif %} {% set use_select2 = sonata_config is defined and sonata_config.getOption('use_select2') %} {% endif %} {% endapply %} {% endblock choice_widget_collapsed %} {% block date_widget %} {% apply 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 %} {% endapply %} {% endblock date_widget %} {% block time_widget %} {% apply 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 %} {% endapply %} {% endblock time_widget %} {% block datetime_widget %} {% apply 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 %} {% endapply %} {% endblock datetime_widget %} {% block form_row %} {% set show_label = show_label ?? true %} {% set row_id = 'sonata-ba-field-container-'~id %} {% set row_class = (row_attr.class|default('') ~ ' form-group' ~ (errors|length > 0 ? ' has-error'))|trim %} {% 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 %} {{ form_help(form) }}
{% 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 %} {% apply spaceless %}
{% if allow_delete %}
{% endif %} {{ form_row(child, { label: false }) }} {% if allow_delete %}
{% endif %}
{% endapply %} {% endblock sonata_type_native_collection_widget_row %} {% block sonata_type_native_collection_widget %} {% apply 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 %}
{% endapply %} {% endblock sonata_type_native_collection_widget %} {% block sonata_type_immutable_array_widget %} {% apply spaceless %}
{{ form_errors(form) }} {% for key, child in form %} {{ block('sonata_type_immutable_array_widget_row') }} {% endfor %} {{ form_rest(form) }}
{% endapply %} {% endblock sonata_type_immutable_array_widget %} {% block sonata_type_immutable_array_widget_row %} {% apply 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 %}
{% endapply %} {% 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') }} {# Taking the form name excluding ending field glue character #} {% set main_form_name = id|slice(0, (id|length - name|length)-1) %} {% if expanded %} {% set js_selector = '#' ~ main_form_name ~ '_' ~ name ~ ' input' %} {% set js_event = 'ifChecked' %} {% else %} {% set js_selector = '#' ~ main_form_name ~ '_' ~ name %} {% set js_event = 'change' %} {% endif %} {% endblock %} {% block sonata_type_choice_multiple_sortable %} {% endblock %} {% block sonata_type_model_list_widget %}
{% if sonata_admin.value and sonata_admin.field_description.associationadmin.urlSafeIdentifier(sonata_admin.value) is not null %} {{ render(path('sonata_admin_short_object_information', { '_sonata_admin': sonata_admin.field_description.associationadmin.baseCodeRoute, 'objectId': sonata_admin.field_description.associationadmin.urlSafeIdentifier(sonata_admin.value), 'uniqid': sonata_admin.field_description.associationadmin.uniqid, 'linkParameters': sonata_admin.field_description.option('link_parameters', {}) } + ( sonata_admin.field_description.associationadmin.hasRequest() ? sonata_admin.field_description.associationadmin.request.attributes.get('_route_params', {}) : {} ) + app.request.query.all|default({}) )) }} {% elseif sonata_admin.field_description.option('placeholder', 'short_object_description_placeholder') %} {{ sonata_admin.field_description.option('placeholder', 'short_object_description_placeholder')|trans({}, 'SonataAdminBundle') }} {% endif %} {% if sonata_admin.field_description.associationadmin.hasroute('list') and sonata_admin.field_description.associationadmin.hasAccess('list') and btn_list %} {# NEXT_MAJOR: Remove the fallback on null and on btn_catalogue #} {{ btn_translation_domain|default(null) is same as(false) ? btn_list : btn_list|trans({}, btn_translation_domain|default(btn_catalogue)) }} {% endif %} {% if sonata_admin.field_description.associationadmin.hasroute('create') and sonata_admin.field_description.associationadmin.hasAccess('create') and btn_add %} {# NEXT_MAJOR: Remove the fallback on null and on btn_catalogue #} {{ btn_translation_domain|default(null) is same as(false) ? btn_add : btn_add|trans({}, btn_translation_domain|default(btn_catalogue)) }} {% endif %} {% if sonata_admin.field_description.associationadmin.hasroute('edit') and sonata_admin.field_description.associationadmin.hasAccess('edit') and btn_edit %} {# NEXT_MAJOR: Remove the fallback on null and on btn_catalogue #} {{ btn_translation_domain|default(null) is same as(false) ? btn_edit : btn_edit|trans({}, btn_translation_domain|default(btn_catalogue)) }} {% endif %} {% if btn_delete %} {% endif %} {# Hidden text input cannot be required, because browser will throw error "An invalid form control with name='' is not focusable" #} {{ form_widget(form, {'required':false}) }}
{% include '@SonataAdmin/CRUD/Association/edit_many_script.html.twig' %} {% endblock %} {% block sonata_type_template_widget %} {% include template with parameters only %} {% endblock sonata_type_template_widget %}