Get the resource form in custom action
Hi!
I've been researching and messing around with forms for a few days and hours now.
Researching filament package code and even plugins i still couldn't figure out how to use the form i created in my relationshipmanager in my custom action.
So i basically have a TeamRelationshipManager where i have created a form in.
Next i added a custom made action within the headeraction.
In my custom made action, i rewrote the form because i couldn't figure out how to use the form i created in the relationship manager.
Any ideas?
3 Replies
Hello!
Bump
something like this works, I use it in some places:
public function form(Form $form): Form
{
return MaintenanceResource::form($form);
}
in an optionForm you cant use it like that, then you need to make a seperate function for just returning the form, sth like this:
public static function getFormSchema(bool $optionForm = false): array
{
return [
Forms\Components\Section::make()
->schema([
Forms\Components\Section::make()
->schema([
Forms\Components\TextInput::make('name')
->label(__('Name'))
->unique(ignoreRecord: true)
->required()
->maxLength(255),
])
];
}
And in the optionForm you use:
static::getFormSchema()
More examples you can find in the official FilamentDemo on github.
Thank you!!!