platform
platform copied to clipboard
branch 11.0.1 Upload field - removing files
Files not removing from html Hi! For the bunch of reasons I'm stuck with 11.0.1 and I found that when clicking the button remove on the thumbnail of the picture, the thumbnail is beeing removed but the hidden input field not. So the request contains those ids of the files. I believe this is fixed in new releases :)
To Reproduce Steps to reproduce the behavior:
- Create screeen with upload
- Create model that will contain the attachments
- Upload some files and save them to model.
- Open that screen again.
- Remove some file
if take a look through the html of the widget you can see those hidden inputs wilth the file ids like that
<input type="hidden" class="files-31" name="attachments[]" value="31">
So when saving, the request will contain the "removed" ids.
Expected behavior The request should not contain the ids of the removed files
Additional context This can be fixed in upload_controller.js
this.on('removedfile', file => {
if (file.hasOwnProperty('id')) { //the file contains not data.id but id
$(dropname).find(`.files-${file.id}`).remove();
!isMediaLibrary && axios
.delete(urlDelete + file.id, {
storage: storage,
})
.then();
}else if (file.hasOwnProperty('data.id')) { //old behavoir
$(dropname).find(`.files-${file.data.id}`).remove();
!isMediaLibrary && axios
.delete(urlDelete + file.data.id, {
storage: storage,
})
.then();
}
});
may be I should do pull request to fix that in that branch?
On version 13.0 it solved.