© 2026 Hedgehog Software, LLC

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

Multiple dependant fields / clearing on change

Hi all,

I am trying to create a bunch of dependent fields where season_id depends on series_id, event_id then depends on season_id and session_id then depends on event_id!

The method I have created works initially, but if I go back to edit the fields the selects retain the value. Is there a way I can force clear the value when one of the dependent field has changed?

Here is my code:

Forms\Components\Section::make('Relationships')
->columns()
->schema([
    Forms\Components\Select::make('series_id')
        ->live()
        ->relationship('series', 'name'),

    Forms\Components\Select::make('season_id')
        ->live()
        ->disabled(fn ($get): bool => ! filled($get('series_id')))
        ->relationship(
            'season',
            'name',
            fn ($get, $query) => $query->where('series_id', $get('series_id'))
        ),

    Forms\Components\Select::make('event_id')
        ->live()
        ->disabled(fn ($get): bool => ! filled($get('season_id')))
        ->relationship(
            'event',
            'name',
            fn ($get, $query) => $query->where('season_id', $get('season_id'))
        ),

    Forms\Components\Select::make('session_id')
        ->live()
        ->disabled(fn ($get): bool => ! filled($get('event_id')))
        ->relationship(
            'session',
            'name',
            fn ($get, $query) => $query->where('event_id', $get('event_id'))
        ),
]),
Forms\Components\Section::make('Relationships')
->columns()
->schema([
    Forms\Components\Select::make('series_id')
        ->live()
        ->relationship('series', 'name'),

    Forms\Components\Select::make('season_id')
        ->live()
        ->disabled(fn ($get): bool => ! filled($get('series_id')))
        ->relationship(
            'season',
            'name',
            fn ($get, $query) => $query->where('series_id', $get('series_id'))
        ),

    Forms\Components\Select::make('event_id')
        ->live()
        ->disabled(fn ($get): bool => ! filled($get('season_id')))
        ->relationship(
            'event',
            'name',
            fn ($get, $query) => $query->where('season_id', $get('season_id'))
        ),

    Forms\Components\Select::make('session_id')
        ->live()
        ->disabled(fn ($get): bool => ! filled($get('event_id')))
        ->relationship(
            'session',
            'name',
            fn ($get, $query) => $query->where('event_id', $get('event_id'))
        ),
]),


Thanks!
image.png
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 form fields based on dependant fields
FilamentFFilament / ❓┊help
3y ago
Suggestion for dependant fields
FilamentFFilament / ❓┊help
2y ago
Dependant select with multiple options
FilamentFFilament / ❓┊help
3y ago
multiple() fields on /create return null
FilamentFFilament / ❓┊help
3y ago