Reusing a form using the form() function from a resource

Greetings, instead of having to have a function that returns an array with the components i.e. getFormSchema(), is it possible to add the form to an action just like in a relation manager as follows?
public function form(Form $form): Form
{
return SubscriptionResource::form($form);
}
public function form(Form $form): Form
{
return SubscriptionResource::form($form);
}
This is what I am currently doing
Tables\Actions\EditAction::make()
->form(UserResource::getFormSchema()),
Tables\Actions\EditAction::make()
->form(UserResource::getFormSchema()),
If I do the following, I will have to click the action twice in order for the info or form to display
Tables\Actions\EditAction::make()
->form(fn ($form) => UserResource::form($form)),
Tables\Actions\EditAction::make()
->form(fn ($form) => UserResource::form($form)),
Solution:
Just create a method that returns the array of form components then call that method anywhere you need to use the form schema. I think you might be doubling up the form initialization.
Jump to solution
3 Replies
Dionysis
DionysisOP16mo ago
Bumping this
Solution
awcodes
awcodes16mo ago
Just create a method that returns the array of form components then call that method anywhere you need to use the form schema. I think you might be doubling up the form initialization.
Dionysis
DionysisOP16mo ago
That's what I am doing right now, I was just hoping there was a similar approach to Relation Managers, thanks tho
Want results from more Discord servers?
Add your server