{% use 'form_div_layout.html.twig' %} {% block form_start -%} {% if 'easyadmin' == block_prefixes|slice(-2)|first %} {% set attr = attr|merge({ 'class': [ _easyadmin_form_type|default('') == 'horizontal' ? 'form-horizontal' : 'form-vertical', attr.class|default(''), easyadmin.view ~ '-form' ]|join(' '), 'data-view': easyadmin.view, 'data-entity': easyadmin.entity.name, 'data-entity-id': attribute(value, easyadmin.entity.primary_key_field_name), }) %} {% endif %} {{- parent() -}} {%- endblock form_start %} {# Widgets #} {% block form_widget %} {{- parent() -}} {% if form.parent.vars.allow_delete|default(false) %} {% set remove_item_javascript %} $(function() { if (event.preventDefault) event.preventDefault(); else event.returnValue = false; var containerDiv = $('#{{ id }}').parents('.form-group:first'); var parentDiv = containerDiv.parents('[data-prototype]:first'); containerDiv.remove(); parentDiv.trigger('easyadmin.collection.item-deleted'); if (0 == parentDiv.children().length && 'undefined' !== parentDiv.attr('data-empty-collection')) { $(parentDiv.attr('data-empty-collection')).insertBefore(parentDiv); } }); {% endset %}
{{ 'action.remove_item'|trans({}, 'EasyAdminBundle') }}
{% endif %} {% endblock form_widget %} {% block form_widget_simple -%} {% if type is not defined or type not in ['file', 'hidden'] %} {%- set attr = attr|merge({class: (attr.class|default('') ~ ' form-control')|trim}) -%} {% endif %} {{- parent() -}} {%- endblock form_widget_simple %} {% block textarea_widget -%} {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-control')|trim}) %} {{- parent() -}} {%- endblock textarea_widget %} {% block button_widget -%} {% set attr = attr|merge({class: (attr.class|default('btn-default') ~ ' btn')|trim}) %} {{- parent() -}} {%- endblock %} {% block money_widget -%}
{% set prepend = '{{' == money_pattern[0:2] %} {% if not prepend %} {{ money_pattern|replace({ '{{ widget }}':''}) }} {% endif %} {{- block('form_widget_simple') -}} {% if prepend %} {{ money_pattern|replace({ '{{ widget }}':''}) }} {% endif %}
{%- endblock money_widget %} {% block percent_widget -%}
{{- block('form_widget_simple') -}} %
{%- endblock percent_widget %} {% block datetime_widget -%} {% if widget == 'single_text' %} {{- block('form_widget_simple') -}} {% else -%} {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%}
{{- form_errors(form.date) -}} {{- form_errors(form.time) -}} {{- form_widget(form.date, { datetime: true } ) -}} {{- form_widget(form.time, { datetime: true } ) -}}
{%- endif %} {%- endblock datetime_widget %} {% block date_widget -%} {% if widget == 'single_text' %} {{- block('form_widget_simple') -}} {% else -%} {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%} {% if datetime is not defined or not datetime -%}
{%- endif %} {{- date_pattern|replace({ '{{ year }}': form_widget(form.year), '{{ month }}': form_widget(form.month), '{{ day }}': form_widget(form.day), })|raw -}} {% if datetime is not defined or not datetime -%}
{%- endif -%} {% endif %} {%- endblock date_widget %} {% block time_widget -%} {% if widget == 'single_text' %} {{- block('form_widget_simple') -}} {% else -%} {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%} {% if datetime is not defined or false == datetime -%}
{%- endif -%} {{- form_widget(form.hour) }}:{{ form_widget(form.minute) }}{% if with_seconds %}:{{ form_widget(form.second) }}{% endif %} {% if datetime is not defined or false == datetime -%}
{%- endif -%} {% endif %} {%- endblock time_widget %} {% block choice_widget_collapsed -%} {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-control')|trim}) %} {{- parent() -}} {% if form.parent.vars.allow_delete|default(false) %} {% set remove_item_javascript %} $(function() { if (event.preventDefault) event.preventDefault(); else event.returnValue = false; var containerDiv = $('#{{ id }}').parents('.form-group:first'); var parentDiv = containerDiv.parents('[data-prototype]:first'); containerDiv.remove(); parentDiv.trigger('easyadmin.collection.item-deleted'); if (0 == parentDiv.children().length && 'undefined' !== parentDiv.attr('data-empty-collection')) { $(parentDiv.attr('data-empty-collection')).insertBefore(parentDiv); } }); {% endset %}
{{ 'action.remove_item'|trans({}, 'EasyAdminBundle') }}
{% endif %} {%- endblock %} {% block choice_widget_expanded -%} {% if '-inline' in label_attr.class|default('') -%}
{%- for child in form %} {{- form_widget(child, { parent_label_class: label_attr.class|default(''), translation_domain: choice_translation_domain, }) -}} {% endfor -%}
{%- else -%}
{%- for child in form %} {{- form_widget(child, { parent_label_class: label_attr.class|default(''), translation_domain: choice_translation_domain, }) -}} {% endfor -%}
{%- endif %} {%- endblock choice_widget_expanded %} {% block checkbox_widget -%} {%- set parent_label_class = parent_label_class|default(label_attr.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(label_attr.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 -%} {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' control-label')|trim}) -%} {{- parent() -}} {%- endblock form_label %} {% block choice_label -%} {# remove the checkbox-inline and radio-inline class, it's only useful for embed labels #} {%- set label_attr = label_attr|merge({class: label_attr.class|default('')|replace({'checkbox-inline': '', 'radio-inline': ''})|trim}) -%} {{- block('form_label') -}} {% endblock %} {% block checkbox_label -%} {{- block('checkbox_radio_label') -}} {%- endblock checkbox_label %} {% block radio_label -%} {{- block('checkbox_radio_label') -}} {%- endblock radio_label %} {% block checkbox_radio_label %} {# Do no 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 -}} {{- label is not same as(false) ? label|trans({}, translation_domain ?: easyadmin.entity.translation_domain) -}} {% endif %} {% endblock checkbox_radio_label %} {# Rows #} {% block form_row -%} {% set _field_type = easyadmin.field.fieldType|default('default') %}
{% set _field_label = easyadmin.field['label']|default(null) %} {{- form_label(form, _field_label, { translation_domain: translation_domain ?: easyadmin.entity.translation_domain }) -}} {{- form_widget(form) -}} {% if _field_type in ['datetime', 'date', 'time', 'birthday'] and easyadmin.field.nullable|default(false) %}
{% endif %} {{- form_errors(form) -}} {% if easyadmin.field.help|default('') != '' %} {{ easyadmin.field.help|trans(domain = easyadmin.entity.translation_domain)|raw }} {% endif %}
{%- endblock form_row %} {% block collection_row %} {{ block('form_row') }} {% if allow_add|default(false) %} {% set js_add_item %} $(function() { if (event.preventDefault) event.preventDefault(); else event.returnValue = false; var collection = $('#{{ id }}'); // Use a counter to avoid having the same index more than once var numItems = collection.data('count') || collection.children('div.form-group').length; collection.prev('.collection-empty').remove(); var newItem = collection.attr('data-prototype') .replace(/\>__name__label__\' + numItems + '<') .replace(/_{{ name }}___name__/g, '_{{ name }}_' + numItems) .replace(/{{ name }}\]\[__name__\]/g, '{{ name }}][' + numItems + ']') ; // Increment the counter and store it in the collection collection.data('count', ++numItems); collection.append(newItem).trigger('easyadmin.collection.item-added'); }); {% endset %}
{{ (form|length == 0 ? 'action.add_new_item' : 'action.add_another_item')|trans({}, 'EasyAdminBundle') }}
{% endif %} {% endblock collection_row %} {% block button_row -%}
{{- form_widget(form) -}}
{%- endblock button_row %} {% block choice_row -%} {% set force_error = true %} {{- block('form_row') }} {%- endblock choice_row %} {% block date_row -%} {% set force_error = true %} {{- block('form_row') }} {%- endblock date_row %} {% block time_row -%} {% set force_error = true %} {{- block('form_row') }} {%- endblock time_row %} {% block datetime_row -%} {% set force_error = true %} {{- block('form_row') }} {%- endblock datetime_row %} {% block checkbox_row -%}
{{- form_widget(form) -}} {{- form_errors(form) -}}
{%- endblock checkbox_row %} {% block radio_row -%}
{{- form_widget(form) -}} {{- form_errors(form) -}}
{%- endblock radio_row %} {# Errors #} {% block form_errors %} {% set error_count = errors|length %} {% if error_count >= 1 %}
{{ 'errors'|transchoice(error_count, {}, 'EasyAdminBundle') }} {% if error_count == 1 %} {{ errors|first.message }} {% else %} {% endif %}
{% endif %} {% endblock form_errors %} {%- block form_widget_compound -%} {# the "is iterable" check is needed because if an object implements __toString() and returns an empty string, "is empty" returns true even if it's not a collection #} {% if value is iterable and value is empty %} {{ block('empty_collection') }} {% endif %} {% if value is iterable and value is empty or form.vars.prototype is defined %} {% set attr = attr|merge({'data-empty-collection': block('empty_collection') }) %} {% endif %} {{ parent() }} {%- endblock form_widget_compound -%} {% block empty_collection %}
{{ include(easyadmin.entity.templates.label_empty) }}
{% endblock empty_collection %} {% block vich_file_row %} {% set force_error = true %} {{ block('form_row') }} {% endblock %} {% block vich_file_widget %} {% spaceless %}
{% if download_uri|default('') is not empty %} {% set download_title = download_uri|split('/')|last ?: 'download'|trans({}, 'VichUploaderBundle') %} {{ download_title }} {% endif %}
{% if form.delete is defined %}
{{ form_row(form.delete, { label: 'action.delete' }) }}
{% endif %}
{{ form_widget(form.file) }}
{% endspaceless %} {% endblock %} {% block vich_image_row %} {% set force_error = true %} {{ block('form_row') }} {% endblock %} {% block vich_image_widget %} {% spaceless %}
{{ form_widget(form.file) }} {% if form.delete is defined %} {{ form_row(form.delete, { label: 'action.delete' }) }} {% endif %} {% if download_uri|default('') is not empty %} {% set _lightbox_id = 'easyadmin-lightbox-' ~ id %}
{% endif %}
{% endspaceless %} {% endblock %} {# EasyAdmin form type #} {% block easyadmin_widget %} {% set _translation_domain = easyadmin.entity.translation_domain %} {% set _trans_parameters = { '%entity_name%': easyadmin.entity.name|trans, '%entity_label%': easyadmin.entity.label|trans } %} {% if form.vars.errors|length > 0 %} {{ form_errors(form) }} {% endif %}
{% for group_name, group_config in easyadmin_form_groups %}
{% if group_config.label|default(false) or group_config.icon|default(false) %}

{% if group_config.icon|default(false) %} {% endif %} {{ group_config.label|trans(domain = _translation_domain)|raw }}

{% endif %}
{% if group_config.help|default(false) %}

{{ group_config.help|trans(domain = _translation_domain)|nl2br|raw }}

{% endif %}
{% for field in form.children if 'hidden' not in field.vars.block_prefixes and field.vars.easyadmin.form_group == group_name %}
{{ form_row(field) }}
{% endfor %}
{% else %} {% for field in form.children if 'hidden' not in field.vars.block_prefixes %}
{{ form_row(field) }}
{% endfor %} {% endfor %}
{% block item_actions %} {# the 'save' action is hardcoded for the 'edit' and 'new' views #} {% set _entity_actions = (easyadmin.view == 'new') ? easyadmin_get_actions_for_new_item(easyadmin.entity.name) : easyadmin_get_actions_for_edit_item(easyadmin.entity.name) %} {% set _entity_id = (easyadmin.view == 'new') ? null : attribute(easyadmin.item, easyadmin.entity.primary_key_field_name) %} {% set _request_parameters = { entity: easyadmin.entity.name, referer: app.request.query.get('referer') } %} {{ include('@EasyAdmin/default/includes/_actions.html.twig', { actions: _entity_actions, request_parameters: _request_parameters, translation_domain: _translation_domain, trans_parameters: _trans_parameters, item_id: _entity_id }, with_context = false) }} {% endblock item_actions %}
{% endblock easyadmin_widget %} {# EasyAdminAutocomplete form type #} {% block easyadmin_autocomplete_widget %} {{ form_widget(form.autocomplete, { attr: attr|merge({ 'data-easyadmin-autocomplete-url' : path('easyadmin', { action: 'autocomplete', entity: autocomplete_entity_name, })|raw }) }) }} {% endblock easyadmin_autocomplete_widget %} {% block easyadmin_autocomplete_inner_label %} {% set name = form.parent.vars.name %} {{- block('form_label') -}} {% endblock easyadmin_autocomplete_inner_label %} {# EasyAdminDivider form type #} {% block easyadmin_divider_row %}

{% endblock easyadmin_divider_row %} {# EasyAdminSection form type #} {% block easyadmin_section_row %} {% set _translation_domain = easyadmin.entity.translation_domain %}
{% if easyadmin.field.label|default(false) or easyadmin.field.icon|default(false) %}

{% if easyadmin.field.icon|default(false) %}{% endif %} {{ easyadmin.field.label|default('')|trans(domain = _translation_domain)|raw }}

{% endif %} {% if easyadmin.field.help|default(false) %}

{{ easyadmin.field.help|trans(domain = _translation_domain)|nl2br|raw }}

{% endif %}
{% endblock easyadmin_section_row %}