Confirmation Alert Before Creating a Record
Hello, I want to add a confirmation alert before creating a record in
Order
model.
I already tried this code in CreateOrder
class but still does not working, the form got submitted without a confirmation alert. Do I missed something? How to solve this?
5 Replies
I'm not sure, but here's a snippet from a v2 project that works for me. Hope it can be useful:
Replacing the
Action
entirelyI've already tried this. In v3,
getSaveFormAction()
does not exists so I change the method to getCreateFormAction()
and change Action::make('save')
to Action::make('create')
but the confirmation alert still does not pop up.
This is my current code. I used the parent CreateRecord
class as a reference.
Yes, so
getSaveFormAction()
is for Edit pages and getCreateFormAction()
for Create pages.
I think you need to remove the ->submit()
for the confirmation modal to work
If I remember correctly, that's why I'm using ->action()
instead in my exampleI changed
->submit('create')
to ->action(fn($livewire) => $livewire->save())
, but the save()
function does not exist.Okay, I changed the code to
$livewire->create()
and now the code is working. Thank you so much for helping me.
Solved Code