© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
14 replies
cigoler

createOptionForm - how to import form schema, is it possible?

I'm using a separate form schema to try and cut down on repetition and mistakes, and so far so good it imports and seems to work:

protected function getFormSchema(): array
    {
        return \App\FormSchemas\UserFormSchema::schema();
    }
protected function getFormSchema(): array
    {
        return \App\FormSchemas\UserFormSchema::schema();
    }


As part of that schema I want there to be a createOptionForm on one of the drop down selects that imports the schema from yet another file (
\App\FormSchemas\CategoryFormSchema::schema()
\App\FormSchemas\CategoryFormSchema::schema()
):

Card::make()
   ->schema([
      Forms\Components\Select::make('category_id')
          ->options(Category::all()->pluck('name', 'id'))
          ->required()
          ->createOptionForm([
                            
          ]),
    ]),
Card::make()
   ->schema([
      Forms\Components\Select::make('category_id')
          ->options(Category::all()->pluck('name', 'id'))
          ->required()
          ->createOptionForm([
                            
          ]),
    ]),


But I'm not sure what I can pass to createOptionForm to make it work, I've tried a bunch of stuff like throwing darts at a board and got nowhere.

I've tried:

->createOptionForm(function () {
              return \App\FormSchemas\CategoryFormSchema::schema();
          }),
->createOptionForm(function () {
              return \App\FormSchemas\CategoryFormSchema::schema();
          }),


Which doesn't throw an error like other options, but when clicking the button nothing happens... is it not possible to nest these imports?
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

How to import form schema
FilamentFFilament / ❓┊help
2y ago
Is it possible to get form from resource and add it to createOptionForm?
FilamentFFilament / ❓┊help
3y ago
is it possible to use mutateFormDataUsing inside createOptionForm
FilamentFFilament / ❓┊help
2y ago
Get Schema from Form for createOptionForm()I
FilamentFFilament / ❓┊help
12mo ago