© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
8 replies
KeyMe

CreateOptionForm in Repeater with dependent select component

I have a Repeater with dependent addon_name select field that ties to the addon_type field. Now I want users to be able to add new add-on name options to the list, like others, the problem is I didn't define the relationship() for the addon_name from the get-go. Bcs as you know I use the customization technique for the dependent name options. How do I go about this?

Select::make('addon_id')->label('Add-on Name')
                    ->options(function (callable $get) {
                        $type = $get('type');

                        if (!$type) {
                            return Addon::pluck('name', 'id');
                        }
                        return Addon::where('type', $type)->pluck('name', 'id');
                    })
                    ->searchable()
                    ->reactive()
                    ->createOptionForm([
                        Select::make('type')->label('Add-on Type')
                            ->options(Addon::pluck('type', 'type'))
                            ->placeholder('Select type')
                            ->required(),
                        TextInput::make('name')->required()
                    ])
                    ->required(),
Select::make('addon_id')->label('Add-on Name')
                    ->options(function (callable $get) {
                        $type = $get('type');

                        if (!$type) {
                            return Addon::pluck('name', 'id');
                        }
                        return Addon::where('type', $type)->pluck('name', 'id');
                    })
                    ->searchable()
                    ->reactive()
                    ->createOptionForm([
                        Select::make('type')->label('Add-on Type')
                            ->options(Addon::pluck('type', 'type'))
                            ->placeholder('Select type')
                            ->required(),
                        TextInput::make('name')->required()
                    ])
                    ->required(),
Solution
->createOptionForm([
    Select::make('type')->label('Add-on Type')
        ->options(Addon::pluck('type', 'type'))
        ->required(),
    TextInput::make('name')->required()
])                            
->createOptionUsing(function (array $data) {
    $addon = Addon::create($data);
    return $addon->id;
})
->createOptionForm([
    Select::make('type')->label('Add-on Type')
        ->options(Addon::pluck('type', 'type'))
        ->required(),
    TextInput::make('name')->required()
])                            
->createOptionUsing(function (array $data) {
    $addon = Addon::create($data);
    return $addon->id;
})
?
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
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Select component with searchable() inside in Repeater component with orderable()
FilamentFFilament / ❓┊help
3y ago
Dependent Select inside wizard with repeater not being populated
FilamentFFilament / ❓┊help
3y ago
Select in repeater
FilamentFFilament / ❓┊help
2y ago