© 2026 Hedgehog Software, LLC

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

Dynamic Fields Based on Select Option Issue

I am encountering a issue with dynamic form fields. When attempting to use any form layout components within the match function the dynamic select jumps to null and nothing else happens (continues to display the default form fields). I haven't received any errors on console for this issue. When not including any layout components the form fields load as expected.

      Forms\Components\Select::make('type')
          ->label('Contest Type')
          ->options([
              'Contest' => 'Contest (single game)',
              'Tournament' => 'Tournament',
          ])
          ->default('Contest')
          ->live()
          ->afterStateUpdated(fn (Forms\Components\Select $component) =>
              $component->getContainer()
                  ->getComponent('dynamicTypeFields')
                  ->getChildComponentContainer()
                  ->fill()
          )
          ->visibleOn('create'),
      Forms\Components\Grid::make(2)
          ->schema(fn (Get $get): array =>
              match ($get('type')) {
                  'Tournament' => [
                      Forms\Components\Fieldset::make() //Remove this and it works
                          ->schema([
                              Forms\Components\TextInput::make('name')
                                  ->required(),
                          ])
                  ],
                  default => [
                      Forms\Components\DateTimePicker::make('start_at')
                      ->label('Date'),
                  ],
              }
          )
          ->key('dynamicTypeFields'),
      Forms\Components\Select::make('type')
          ->label('Contest Type')
          ->options([
              'Contest' => 'Contest (single game)',
              'Tournament' => 'Tournament',
          ])
          ->default('Contest')
          ->live()
          ->afterStateUpdated(fn (Forms\Components\Select $component) =>
              $component->getContainer()
                  ->getComponent('dynamicTypeFields')
                  ->getChildComponentContainer()
                  ->fill()
          )
          ->visibleOn('create'),
      Forms\Components\Grid::make(2)
          ->schema(fn (Get $get): array =>
              match ($get('type')) {
                  'Tournament' => [
                      Forms\Components\Fieldset::make() //Remove this and it works
                          ->schema([
                              Forms\Components\TextInput::make('name')
                                  ->required(),
                          ])
                  ],
                  default => [
                      Forms\Components\DateTimePicker::make('start_at')
                      ->label('Date'),
                  ],
              }
          )
          ->key('dynamicTypeFields'),
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
error in Dynamic fields based on a select option
FilamentFFilament / ❓┊help
2y ago
Dynamic fields based on a select option with Tabs
FilamentFFilament / ❓┊help
3y ago
Dynamic Select Fields
FilamentFFilament / ❓┊help
3y ago