Form actions must be an instance of Filament\Actions\Action, or Filament\Actions\ActionGroup.
hello all good evening, I need help why when I want to create pages an error appears like this
14 Replies
you need to provide your code of the resource.
this code:
Triggers that error. This is the same as the code at this page in the guide:
https://filamentphp.com/docs/3.x/forms/actions#adding-anonymous-actions-to-a-form-without-attaching-them-to-a-component
Where did you put that code?
I assume that your IDE is not using
Please show the full code
I am actually using both
One could argue that the code I'm using, being the same of the startup guide I previously linked, does not matter, bu anyways, here it goes:
https://gist.github.com/FraSaid/e1d10d38e277dec17b0887fcf563242a
The startup guide might be wrong then. Did you try the suggested classes instead?
Your Filament version is up-to-date? Can you share the
artisan about
section for Filament?I'm on 3.0.6, updated my composer this morning. The proble with using the suggested classes is that the "Actions" component for the form takes as input in it's constructor of type array<Action>, where Action comes from use Filament\Forms\Components\Actions\Action;
So I cannot mix and match the suggested classes, as one requires the I would assume, correct one: Filament\Forms\Components\Actions\Action but the mount function breaks if the object is not either a Filament\Actions\Action, or Filament\Actions\ActionGroup
I think the issue it, that you are using the same class for
getHeaderActions()
. You need to use aliases so you can use a different class thereI get it, the Header uses Filament/Actions/Action, and that was not imported or aliased
Thanks a lot Dennis, I wasn't really thinking about the possibility of both having the same name
There are a lot of different Action classes which unfortunately leads to clashes in some cases.
I noticed that yesterday when I extracted my actions into classes. Could that somehow be resolved? I'd be willing to support a PR.
We'd need to prefix them all probably. But they are already prefixed by the namespace. That's what aliases are for. What's your proposed solution?
I implemented every action twice. One of the list item, another of the view page. It's the same logic and I'd like to reduce them to one action since it's duplicated code.
I played around a little bit yesterday, but did not find a solution to reduce them to one action
Ah, right. Not really sure if there's is a good solution. There are different actions for a reason and not everything is supported everywhere. You could reuse your code by extending the base action and then extending the other actions from that. One more class, but no duplicated ode.