Header actions on AdminPanel dashboard
Im trying to add some custom buttons for database actions that where prevoiuly on the list users resource in the table header but I want them on the main dashboard as a custom widget. Any help would be awesome!
Solution:Jump to solution
cacheAction is probably a reserved method name since filament caches actions internally. Try renaming it to something else.
17 Replies
Current code for custom widget, issue being that its not an actual table so this just breaks when you try to click
Really I only need it to look like an action and behave by running custom code
You need to make the actions as methods in the livewire component. You can’t inline them like that in the view. It’s too late to register them in the lifecycle. Widgets are just livewire components. https://filamentphp.com/docs/3.x/actions/adding-an-action-to-a-livewire-component#adding-the-action
Any idea why this isnt working?
You don't need to call render on the action. Just {{ $this->deleteAction }} is enough.
Also. You should name your action to match the method name.
So deleteAction() function should return Action::make('delete')->....
Ok cool thanks, now im getting
This action does not belong to a Livewire component.
it works when I have only one action but as soon as I make more than one it breaks complertlyCheck that you've imported from the correct name space.
use Filament\Actions\Action;
Also make sure your action have the same name as the method.
Yeah they are :/
I did
There also both rendering cache action
Solution
cacheAction is probably a reserved method name since filament caches actions internally. Try renaming it to something else.
That fixed it! Thanks!