{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #}
{% use '@EasyAdmin/symfony-form-themes/bootstrap_5_layout.html.twig' %}
{% block form_start %}
{% if form.vars.errors|length > 0 and 'ea_crud' in form.vars.block_prefixes|default([]) %}
{{ form_errors(form, {attr: { class: 'global-invalid-feedback' }}) }}
{% endif %}
{{ parent() }}
{% if ea.request.query.get('referrer') %}
{% endif %}
{% endblock form_start %}
{% block form_end %}
{% if not render_rest is defined or render_rest %}
{{ form_rest(form) }}
{% endif %}
{% endblock %}
{% block form_errors %}
{% if errors|length > 0 %}
{% for error in errors %}
{{ error.message }}
{% endfor %}
{% endif %}
{% endblock form_errors %}
{# Widgets #}
{% block form_widget_simple -%}
{% if type is not defined or type not in ['file', 'hidden'] %}
{%- set attr = attr|merge({class: (attr.class|default(''))|trim}) -%}
{% endif %}
{%- if type is defined and (type == 'range' or type == 'color') %}
{# Attribute "required" is not supported #}
{%- set required = false -%}
{% endif %}
{{- parent() -}}
{%- endblock form_widget_simple %}
{% block datetime_widget %}
{%- if widget != 'single_text' -%}
{%- set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%}
{%- endif -%}
{%- endblock time_widget %}
{% block file_widget -%}
{% if vich|default(false) %}
{%- set type = type|default('file') -%}
{{- block('form_widget_simple') -}}
{% else %}
{{- block('form_widget_simple') -}}
{% endif %}
{%- endblock %}
{# Rows #}
{% block form_row %}
{% set row_attr = row_attr|merge({
class: row_attr.class|default('') ~ ' form-group'
}) %}
{% set field = form.vars.ea_vars.field %}
{%- set row_class = row_class|default(row_attr.class|default('mb-3')) -%}
{{- form_label(form) -}}
{% set has_prepend_html = field.prepend_html|default(null) is not null %}
{% set has_append_html = field.append_html|default(null) is not null %}
{% set has_input_groups = has_prepend_html or has_append_html %}
{% if has_input_groups %}
{% endif %}
{% if has_prepend_html %}
{{ field.prepend_html|raw }}
{% endif %}
{{ form_widget(form) }}
{% if has_append_html %}
{{ field.append_html|raw }}
{% endif %}
{% if has_input_groups %}
{# if a field doesn't define its columns explicitly, insert a fill element to make the field take the entire row space #}
{% if field.columns|default(null) is null %}
{% endif %}
{% endblock form_row %}
{% block choice_widget_collapsed %}
{% if 'ea-autocomplete' == attr['data-ea-widget']|default(false) %}
{% set attr = attr|merge({
'data-ea-i18n-no-results-found': 'autocomplete.no-results-found'|trans({}, 'EasyAdminBundle'),
'data-ea-i18n-no-more-results': 'autocomplete.no-more-results'|trans({}, 'EasyAdminBundle'),
'data-ea-i18n-loading-more-results': 'autocomplete.loading-more-results'|trans({}, 'EasyAdminBundle'),
}) %}
{% endif %}
{{ parent() }}
{% endblock choice_widget_collapsed %}
{% block collection_row %}
{% if prototype is defined and not prototype.rendered %}
{% set row_attr = row_attr|merge({ 'data-prototype': form_row(prototype) }) %}
{% endif %}
{% set maxKey = 0 %}
{% for key in form.children|keys %}
{% if key matches '/^\\d+$/' %}
{% set intKey = key|number_format(0, '', '', '') %}
{% if intKey > maxKey %}
{% set maxKey = intKey %}
{% endif %}
{% endif %}
{% endfor %}
{% set row_attr = row_attr|merge({
'data-ea-collection-field': 'true',
'data-entry-is-complex': form.vars.ea_vars.field and form.vars.ea_vars.field.customOptions.get('entryIsComplex') ? 'true' : 'false',
'data-allow-add': allow_add ? 'true' : 'false',
'data-allow-delete': allow_delete ? 'true' : 'false',
'data-num-items': form.children is empty ? 0 : maxKey + 1,
'data-form-type-name-placeholder': prototype is defined ? prototype.vars.name : '',
}) %}
{{ block('form_row') }}
{% endblock collection_row %}
{% block collection_widget %}
{# 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 #}
{% set isEmptyCollection = value is null or (value is iterable and value is empty) %}
{% set is_array_field = 'EasyCorp\\Bundle\\EasyAdminBundle\\Field\\ArrayField' == form.vars.ea_vars.field.fieldFqcn|default(false) %}
{% if 'collection' in block_prefixes %}
{# 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 #}
{% set isEmptyCollection = value is null or (value is iterable and value is empty) %}
{% if isEmptyCollection %}
{{ block('empty_collection') }}
{% endif %}
{% if isEmptyCollection or form.vars.prototype is defined %}
{% set attr = attr|merge({'data-empty-collection': block('empty_collection') }) %}
{% endif %}
{% endif %}
{{ parent() }}