© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
5 replies
Dionysis

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()
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
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Use a function (): Action from a Resource ?
FilamentFFilament / ❓┊help
3y ago
Using custom function in a form
FilamentFFilament / ❓┊help
3y ago
Reusing tables and forms from Resources
FilamentFFilament / ❓┊help
3y ago
custom page form from resource
FilamentFFilament / ❓┊help
11mo ago