[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:
public function test(): Action
{
return Action::make('test')
->label('Test action')
->icon('heroicon-o-check')
->action(function () {
Notification::make('test')
->title('Test Action Executed')
->success()
->send();
});
}
public function test(): Action
{
return Action::make('test')
->label('Test action')
->icon('heroicon-o-check')
->action(function () {
Notification::make('test')
->title('Test Action Executed')
->success()
->send();
});
}
And I put this on the blade file
{{$this->test()}}

(Note: I also tried {{ $this->test }} like in V3, but that doesn’t work either.)
{{$this->test()}}

(Note: I also tried {{ $this->test }} like in V3, but that doesn’t work either.)
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:
I got it to work, apparently, it only functions correctly if you explicitly specify the return type as : Action.
Jump to solution
3 Replies
Dennis Koch
Dennis Koch2mo ago
- Did you publish some view files? - Did you try naming the method testAction() (test() should work though).
Luuk Dahlmans
Luuk DahlmansOP2mo ago
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
Luuk Dahlmans
Luuk Dahlmans2mo ago
I got it to work, apparently, it only functions correctly if you explicitly specify the return type as : Action.

Did you find this page helpful?