[Filament V4] Custom page action not executing
Hi everyone,
I'm currently migrating my app to Filament V4 and I've encountered an issue when trying to add actions to a custom simple page.
In V3, I could define an action in the page class and render it in the Blade file like this: {{ $this->myAction }}, and it worked as expected. I'm trying to replicate that behavior in V4, but the action doesn't seem to execute properly when clicked.
Here’s what I’ve done so far:
And I put this on the blade file
The button renders correctly, and I can see a network request being made when I click it, but nothing happens, no notification is shown, and the action callback doesn’t seem to run.
Has the method for handling actions in custom pages changed in V4?
Any help would be appreciated, thanks in advance!
Solution:Jump to solution
I got it to work, apparently, it only functions correctly if you explicitly specify the return type as : Action.
3 Replies
- Did you publish some view files?
- Did you try naming the method
testAction()
(test()
should work though).I got it to work I forgot to add use InteractsWithActions;
use InteractsWithSchemas; and implement the HasActions and HasSchemas, the next problem I have is that the modals do not open. I added <x-filament-actions::modals /> to the view. So the test action above, with the notification works, but if I add requiresConfirmation, it does not show a modal
Solution
I got it to work, apparently, it only functions correctly if you explicitly specify the return type as : Action.