requiresConfirmation not working on actions
I have a Filament page where I have a list of actions (array)
And I am rendering this array like the following:
All is working well, but the requiresConfirmation() is not working the action is called without showing the confirmation dialog.
any idea?
33 Replies
If this is a custom view I think you’re missing the modals component to show the dialog.
Assuming you have <x-filament-actions::modals /> added to your view as per?: https://filamentphp.com/docs/3.x/actions/adding-an-action-to-a-livewire-component#adding-the-action
Oh I see, I will add it and check if it resolves the issue, thanks for you help
I just try it but not working, here is my component:
and the blade view:
but still not working
the HasForms and HasActions and the trait uses are already included in the Page (extended by the class) so it is not required, but added them or not does not change anything
and just checked the x-filament-panel::page used in my class blade view I found that the <x-filament-actions::modals /> is already added
Why not header actions?
https://filamentphp.com/docs/3.x/panels/pages#header-actions
because I have a modal containing some actions on the footer
something like this
and the Delete button must show a confirmation
I tought it was because the actions are showed inside a modal so there is a conflict or something, but I tested the actions outside the modals and the same issue
share the whole code please
@Leandro Ferreira yes of course
here is the blade view
and the method used to retrieve the actions array
The class is much bigger, I remove the useless code
Oh yeah modal inside modal is not supported. I had this issue as well and read something about it being to complex…
i think this is only true for v2
Could be but I have not had any success making it work 🙂 I’m all ears however
i guess it muss be something else
ow I see
I am using Filament v3
I couldn’t get it to work in v3 either, curious if anyone has some knowledge to share about it
it seems only to work when action is a closure and not a string of a function which should be called
already tried this way and also didnt work
Yeah in my case it both ignores the confirmation and the action. I had to do a roundabout way for the action but still no go on the confirmation
I found the solution,
When using a function that defines an array of actions that did not work but when using a function that only defines a single Action it works
So basically what it did work for me is to define a function for each Action that I have and follows the documentation here: https://filamentphp.com/docs/3.x/actions/adding-an-action-to-a-livewire-component/
And all works fine
Would you mind sharing some snippets of your code?
Yes sure, I will do it tonight when I have my laptop
@justlasse
here is for my case:
- Not working example:
In my Livewire Component I have a function that returns all my actions as an array:
Then in my blade view, I loop then render the action:
that works, but like there is no confirmation, it fires directly the action method.
- Now, the working example:
And for the blade view, I render them separatly:
And also a weird behaviour I found, is when you define your Action with the following format, it WORKS:
But with the following format it does not WORK:
So basically, you need to specify a function for each action, then for the requiresConfirmation you need to specify the action as an embedded method in the
action()
myDeleteActionHandler is never registered as an action. Try ->action($this->myDeleteActionHandler())
Thank you 🙏
It’s a bit strange what logic decides on this and how it works internally… I can’t find it in the code.
Actions get cached, during registration (make) so when you try to call a string in the ->action() modifier it is trying to call a cached action by name. If you pass in a closure then it will just execute that closure.
I get this when i try your working code
Try just moving the function into ->action() directly. If you still have problems then the issue is somewhere in that function and not the action itself.
I use an entryview in my infolist, and in the entryview i added the public function for the action, maybe that's the issue?
Don’t know. I’d have to see more code.
That's the part in my infolist for example
Thats the actions "viewactions" class
Blade view
Wait how did you get syntax coloring in the code???
As you can see i've experimented ALOT with these actions
How do you add the action in your infolist? Do you add it directly in the schema or in a component?
```php
```
ohhhh
Seems modals inside a modal infolist in a slideover just doesn't work... it works in the regualr infolist view but not when it's called in the slideover