z-song / laravel-admin

Build a full-featured administrative interface in ten minutes
https://laravel-admin.org
MIT License
11.15k stars 2.82k forks source link

HasMany field Items not deleted after Form validation fails #5820

Open alexoleynik0 opened 1 year ago

alexoleynik0 commented 1 year ago

Description:

Assuming you have a Form with HasMany field used, and you decided to delete already existing Item from there, but Form validation failed somewhere - on the second render you won't see those Items you previously removed, but if Form submission now succeeds you will get that removed item back as it won't be passed with form data to be removed on the second time.

Steps To Reproduce:

I assume the solution could be in the HasMany::buildRelatedForms method on the lines where it skips Items that has remove_flag checked. Maybe there should be some check if that Item has ID and then render only hidden input with remove_flag for that Item, so it could be removed on valid Form submission.