© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
1 reply
Fzoltan87

Dynamic fields based on a select option with Tabs

My problem is as follows: On the create page, when I select a product type on the "Default TAB" tab, the form associated with that product type should load on the "Data TAB" tab. This works on the create page, the data is entered insert the database. However, when I open the editing page, even though the product type is loaded back from the database, the "Data TAB" on the second tab remains empty – the corresponding form is not loaded. In fact, nothing is loaded. What could be the solution?

    Tab::make('Default TAB')
    ->schema([
        Select::make('type_id')->label(__('Product Type'))->required()->searchable()
        ->options(\App\Models\List\ProductType::orderBy('id', 'asc')->pluck('name', 'id')->toArray())
        ->live(),
    ])->columns(4),
     
    Tab::make('Data TAB')
    ->schema(fn (Get $get): array => match ($get('type_id')) {
        default => [],
        '1' => [ProductDataContactLensForm::make('cldata')->columns(4)],
        '3' => [ProductDataSunGlassForm::make('sgdata')->columns(4)],
        '5' => [ProductDataSpectacleFrameForm::make('sfdata')->columns(4)],
    }),
    Tab::make('Default TAB')
    ->schema([
        Select::make('type_id')->label(__('Product Type'))->required()->searchable()
        ->options(\App\Models\List\ProductType::orderBy('id', 'asc')->pluck('name', 'id')->toArray())
        ->live(),
    ])->columns(4),
     
    Tab::make('Data TAB')
    ->schema(fn (Get $get): array => match ($get('type_id')) {
        default => [],
        '1' => [ProductDataContactLensForm::make('cldata')->columns(4)],
        '3' => [ProductDataSunGlassForm::make('sgdata')->columns(4)],
        '5' => [ProductDataSpectacleFrameForm::make('sfdata')->columns(4)],
    }),
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

Dynamic fields based on a select option
FilamentFFilament / ❓┊help
3y ago
Dynamic Fields Based on Select Option Issue
FilamentFFilament / ❓┊help
3y ago
error in Dynamic fields based on a select option
FilamentFFilament / ❓┊help
2y ago
Dynamic Select Fields
FilamentFFilament / ❓┊help
3y ago