#19201·Sylius

[UiBundle] Deleted product image comes back after "Add image"

Author: Florian-MerleCreated Sep 1, 2026Updated Sep 17, 2026
LabelsPotential Bug

Sylius version(s) affected

2.0

Description

When you remove an item from a live collection and then add a new one, the removed item comes back.

Removing an item frees its index, so the next added item takes the same index. The form then binds this new empty item on the item that the resource still has, instead of creating a new one. The removed item is restored with everything that is not a form field, like the path of an image.

It only happens when you remove the highest index. With a collection with only 1 element it happens every time, so you cannot replace an image with remove + add.

How to reproduce

This can be reproduced on the demo.

  1. Edit a product
  2. Delete its image
  3. Click "add image"
  4. A new item appears at index 0, showing the thumbnail of the image deleted in step 2
  5. Submit the form
  6. The product still has the image, no form error is displayed

https://github.com/user-attachments/assets/b2aee74a-5ceb-4b4a-9402-56844419ec52

Possible Solution

Haven't looked into it too much, but https://github.com/Sylius/Sylius/blob/2.0/src/Sylius/Bundle/UiBundle/Twig/Component/LiveCollectionTrait.php should be fixed. I'll try to look into it soon.

Additional Context

No response