How to make my custom Prebuilt Actions?
Hello everyone.
I want to make my own custom Prebuilt Actions.
Here are the default ones https://filamentphp.com/docs/3.x/actions/prebuilt-actions/create
I want to make my own, for example WatchAction. I can make a custom action with a form, but I want to use it on different resources without duplicating the full code. How can I do this? I don't see a command to create a custom action.
9 Replies
just create a normal action class and use it anywhere you want
you can start by copying any prebuilt ones and place them like in
app/filamnet/actions
example:
https://github.com/lara-zeus/bolt/blob/3.x/src/Filament/Actions/SetResponseStatus.phpThanks. I thought about this solution, but I didn't know exactly where to put the file.
So the optimal location is app/Filament/Actions?
the optimal location is wherever you want and however you want to structure your app 🙂
but yea,
app/Filament/Actions
is a good locationHow to make a universal Action? So that it is suitable for both tables and pages. If I use Action from tables in pages, then there will be an error "Header actions must be an instance of Filament\Actions\Action, or Filament\Actions\ActionGroup". Is it possible to make a universal one?
this been answered many times before, if you searched
"one Action"
Can't find "one Action" in discord topics(((
google works too
https://github.com/filamentphp/filament/discussions/10310
GitHub
Reuse action in both Table and Header · filamentphp filament · Disc...
Hi all, Is there a way to use an action sometimes as a headerAction and sometimes as a table action? I don't want to duplicate my code. I have a ressource list header action: protected function...
It's not really possible currently to make a "universal action".
My solution. I don't know how reliable it is, but it works.
app/Filament/Actions/WatchAction.php