createAction inside form section
Colleagues, how to connect the createAction with a form, I really need to be able to add an item to the relationship based on a checkboxList, and under it a button add an item using createAction and editAction, but these are incompatible types with the form.
9 Replies
This is an example for
use Filament\Forms\Components\Actions\Action;
It doesn't work with
use Filament\Actions\CreateAction;
These are different types and only CreateAction has the ability to assign a record other than the one assigned to the main form
Sounds like you need a custom action instead of a prebuilt one.
If you want it inside a form though you have to do what a shared.
However, I would like to find a way to assign a predefined CreateAction to which I can assign a record and relationships to the form. Custom form action does not provide such possibilities
It does. CreateAction is just an extension of one of the Action classes. You can make your own action that does the same and reuse it in any form you’d like to.
You can pass ->record() to any action. And the relationships are managed by the fields in the action’s form anyway.
What record are you trying to assign to the action?
Is it tied to an existing field in the form?
NO. EditAction accepts any model and I would like to indicate that it should inherit from the form in which it is placed.
Since editAction is a stand-alone action not associated with any element, I would like to simply be able to place it on a form, but not integrate any aspects of its operation with that form. Just like I would put it in the livewire component
Well you can't just add any action anywhere. it's something we would like to try to do this year in Filament. But, as of now. Any action inside a form has to be a Form Component Action, any action inside a Table has to be a Table Action, and any action outside of those has to be an Action. There's a good explanation of what to use where on this page in the docs. https://filamentphp.com/docs/3.x/actions/overview