{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #} {# @see src/Resources/views/crud/form_theme.html.twig #} {# @see vendor/easycorp/easyadmin-bundle/src/Resources/views/crud/form_theme.html.twig #} {# ## Modifictions are only in the include of /easy_admin/* custom templates #} {# ## All modifictions should be in partial only #} {% block ea_fileupload_widget %} {# We don't use the existing EA currentFiles variable as it doesn't contains correct values with the cloud storage (prod env) #} {# because EA tries to create UploadedFile instances from the local path, and it doesn't find anything. #} {# Instead, we can just get the images path from our entities and use the custom flysystem path helpers #} {% set entity = ea.entity.instance %} {% set current_files = is_images_entity(entity) ? entity.images : [entity.image] %} {% set current_files = (current_files ?? [])|filter(v => v is not null) %} {# no error with new image #}
{% set placeholder = t('action.choose_file', {}, 'EasyAdminBundle') %} {% set title = '' %} {% set files_label = 'files'|trans({}, 'EasyAdminBundle') %} {% set placeholder = (current_files|length) > 0 ? current_files|length ~ ' ' ~ files_label : placeholder %}
{{ form_widget(form.file, {attr: form.file.vars.attr|merge({placeholder: placeholder, title: title, 'data-files-label': files_label, style: 'display: none'})}) }} {{ form_label(form.file, placeholder, {label_attr: {class: 'custom-file-label'}}) }}
{% if allow_delete %} {% endif %}
{% if current_files is not empty and form.vars.valid %}
{# If multiple file is not acticated we just have one file #} {% for file in current_files %} {# get public URL of resource depending on if it has multiple images associated or not #} {% set public_url = is_images_entity(entity) ? entity|public_url_image(file) : entity|public_url %} {% endfor %}
{% set html_id = 'ea-lightbox-' ~ loop.index %} {{ file }}
{{ entity.name ?? '' }}
{{ entity.name ?? '' }}
{% endif %} {% if allow_delete %}
{{ form_widget(form.delete, {label: false}) }}
{% endif %}
{{ form_errors(form.file) }} {% include 'easy_admin/crud/_js_upload_size_validation.html.twig' %} {% endblock %}