Is there any way to ask user confirmation before file is removed from FileUpload field?

I did not find any way to to ask the user a confirmation pop up when user click on X icon in the form. Is there any way to do so?
10 Replies
toeknee
toeknee15mo ago
I doubt it, but check if requiresConfirmation() exists on the field
nitinkaware
nitinkaware15mo ago
The requiresConfirmation method exits on the action, and not on the field. The file pond do. have a beforeRemoveFile callback, but I am not sure how can I hook it into JS.
awcodes
awcodes15mo ago
Maybe some insight at https://pqina.nl/filepond/docs/api/instance/events/ if you can find the right even to listen to you can tigger a Filament notification via JS.
Easy File Uploading With JavaScript | FilePond
A JavaScript library that can upload anything you throw at it, optimizes images for faster uploads, and offers a great, accessible, silky smooth user experience.
nitinkaware
nitinkaware15mo ago
Thanks, I figured out that I can override the FilePond field and create my own view and in that view, I can have something like the below in JS
FilePond.setOptions({
beforeRemoveFile: function () { return confirm("Are you sure?"); }
})
FilePond.setOptions({
beforeRemoveFile: function () { return confirm("Are you sure?"); }
})
What I want now is that is there any way to fire up the native confirmation action that Filament has. for e.g like requiresConfirmation?
Dan Harrin
Dan Harrin15mo ago
there is not a way to do that, no
Mark Chaney
Mark Chaney15mo ago
I agree that it’s really needed
awcodes
awcodes15mo ago
Checkout the docs. You can fire notifications from JavaScript. Maybe dans right though.
Dan Harrin
Dan Harrin15mo ago
awaiting a yes/no response is the tricky part
awcodes
awcodes15mo ago
Yea, I can see that.
nitinkaware
nitinkaware15mo ago
Yes, for notification it's possible. But for the confirmation pop-up, as of now, it's not possible as mentioned. I will try to figure it out if I can find a way. Thanks for the help