F
Filament7mo ago
KeyMe

Confirmation message on custom action modal

I had an expectation that chaining the requiresConfirmation() method to my custom page action in which form() and action() is defined would display the confirmation modal only when submit button is click. However, it displays as part of the action modal instead. Would appreciate any help to tackle this. p/s: the whole purpose of this is to prevent user accidentally submit on enter.
No description
Solution:
Solved it, it's 'wire:click' => 'callMountedAction([])'.
Jump to solution
11 Replies
toeknee
toeknee6mo ago
No, requiresConfirmation is used on actions that are automatic. I.e. toggling etc. By injecting a form into it, you make it a confirm. What you want to do is remove the confirmation option since you have a popup form by placing form in there already.
KeyMe
KeyMe6mo ago
so my form became the confirmation.. i see welp
toeknee
toeknee6mo ago
Yep!
KeyMe
KeyMe6mo ago
guess i'll just educate the user to double check their info lol
toeknee
toeknee6mo ago
Yep... But if you want to confirm, you could place a basic wire:confirm as an extra atribute on a custom submit button? https://livewire.laravel.com/docs/wire-confirm
Laravel
wire:confirm | Laravel
A full-stack framework for Laravel that takes the pain out of building dynamic UIs.
KeyMe
KeyMe6mo ago
i'll give it a try, so using makemodalsubmitaction? extramodalfooteractions?
toeknee
toeknee6mo ago
modalActions IIRC, been a while since i have done it
KeyMe
KeyMe6mo ago
This ends up being my solution aha, it both prevent submit on enter and displays an ugly browser confirmation message
->modalSubmitAction(
fn (StaticAction $action) => $action->extraAttributes(['type' => 'button', 'wire:click' => 'save', 'wire:confirm' => 'Proceed?'])
)
->modalSubmitAction(
fn (StaticAction $action) => $action->extraAttributes(['type' => 'button', 'wire:click' => 'save', 'wire:confirm' => 'Proceed?'])
)
not really sure how to customize the modal nvm shortlived, it couldnt find 'save' method when submitted
toeknee
toeknee6mo ago
You'll need to make the action a SaveAction not StaticAction I believe? The confirmation message for livewire is just a browser JavaScript one tbh
KeyMe
KeyMe6mo ago
there's a SaveAction?
Solution
KeyMe
KeyMe6mo ago
Solved it, it's 'wire:click' => 'callMountedAction([])'.