{% if type == 'new' %} {{ form_start(form, { 'action': path('new_promotion', { mode: 'produit' }), 'method': 'POST', 'attr': { 'class': 'm-form m-form--fit m-form--label-align-right' } }) }} {% else %} {{ form_start(form, { 'action': path('edit_promotion', { 'id': promotion.id }), 'method': 'POST', 'attr': { 'class': 'm-form m-form--fit m-form--label-align-right' } }) }} {% endif %} {% if type != 'new' and promotion is defined %} {% endif %}
{# --- Modale Sélecteur de produits --- #} {{ form_errors(form) }} {{ form_rest(form) }} {{ form_end(form) }} est posé côté Twig pour l'édition #} if (window._promotionSelectedProducts && Array.isArray(window._promotionSelectedProducts)) { window._promotionSelectedProducts.forEach(function(p){ finalSelected[p.id] = p; }); renderFinalSelection(); } else { {# fallback : si des inputs cachés existent (ex: après une validation échouée) #} $('#selectedProductInputs input[type="hidden"]').each(function(){ var id = $(this).val(); if (id) finalSelected[id] = { id:id, ref:'', name:'', imageUrl:null }; }); renderFinalSelection(); } {# (NOUVEAU) RESET / REHYDRATE à l'ouverture de la modale "Promotion" #} $(document).on('shown.bs.modal', '#m_modal_promotion', function () { {# 1) Vider la sélection en mémoire + UI (cas "New" surtout) #} pickerSelected = {}; finalSelected = {}; renderFinalSelection(); {# 2) Vider le