{#--Onglet images--#}
{% if "PRODUIT_UPDATE" in rights %} {{ form_start(formFile, {'action': path('produit_file', {'id': produit.id}),'method': 'POST', 'attr': {'class': 'js-product-upload-images-form'} }) }}
{#-- Galerie des images --#} {% if produit.picture %} {# ================= ACTIONS ================= #}
{#-- Barre d’actions: gauche = affectation; droite = icônes seules --#}
{# ================= LEFT ================= #}
{% set pos1Values = [] %} {% set pos1ValueLabels = [] %} {% set pos1DeclinationName = '' %} {% for pdv in produit.produitDeclinationValues %} {% for gv in pdv.groupDeclinationValues %} {% if gv.declination.position == 1 and gv.value.id not in pos1Values %} {% set pos1Values = pos1Values|merge([gv.value.id]) %} {% set pos1ValueLabels = pos1ValueLabels|merge([gv.value.name]) %} {% if pos1DeclinationName == '' %} {% set pos1DeclinationName = gv.declination.name %} {% endif %} {% endif %} {% endfor %} {% endfor %} {% set dynamicMaxPhotos = (pos1Values|length > 0) ? (pos1Values|length * 6) : 12 %}
Existantes: {{ produit.picture|length }} En attente: 0 Max: {{ dynamicMaxPhotos }}
{{ form_widget(formFile.picture, { 'attr': { 'class': 'form-control m-input', 'accept': 'image/*', 'multiple': true, 'data-max-total-images': dynamicMaxPhotos, 'data-max-file-size': (8 * 1024 * 1024) } }) }} Formats acceptés : JPG, PNG — sélection multiple autorisée
0 sélectionnée
{% if pos1Values|length == 1 %}
Info Affectation automatique disponible
{{ form_widget(formFile.autoAssignPositionOne, { attr: { class: 'form-check-input mt-1 ms-0' } }) }}
Option utile quand le produit n'a qu'une seule valeur pour {{ pos1DeclinationName|default('cette déclinaison') }}. {% endif %}
{{ form_widget(formFile.save, { 'attr': {'class': 'btn crm-btn-dark px-5 py-2 w-md-auto', 'id': 'saveProductImagesBtn', 'type': 'button'}, 'label': 'Enregistrer les images' }) }}
{% else %}
Aucune image n’est disponible pour ce produit.
{% endif %} {% if pos1Values|length != 1 %} {% do formFile.autoAssignPositionOne.setRendered %} {% endif %} {{ form_errors(formFile) }} {{ form_rest(formFile) }} {{ form_end(formFile) }}
{% endif %}