© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3mo ago•
2 replies
blntgvn42

how to change selectfilter options based on another selectfilter?

Hello, I have this city and district select options. In form, I can bring districts that belongs to the city. How can I perform same operation in SelectFilter component. I have read documents but couldn't find the solution

Select::make('city_id')
    ->label('Şehir')
    ->relationship('city', 'name')
    ->searchable()
    ->preload()
    ->required()
    ->live()
    ->afterStateUpdated(fn($state, $set) => $set('district_id', null)),

Select::make('district_id')
    ->label('İlçe')
    ->options(function ($get) {
        $cityId = $get('city_id');
        if ( ! $cityId) {
            return [];
        }

        return District::where('city_id', $cityId)
            ->orderBy('name')
            ->pluck('name', 'id');
    })
    ->searchable()
    ->preload()
    ->disabled(fn($get) => ! $get('city_id')),
Select::make('city_id')
    ->label('Şehir')
    ->relationship('city', 'name')
    ->searchable()
    ->preload()
    ->required()
    ->live()
    ->afterStateUpdated(fn($state, $set) => $set('district_id', null)),

Select::make('district_id')
    ->label('İlçe')
    ->options(function ($get) {
        $cityId = $get('city_id');
        if ( ! $cityId) {
            return [];
        }

        return District::where('city_id', $cityId)
            ->orderBy('name')
            ->pluck('name', 'id');
    })
    ->searchable()
    ->preload()
    ->disabled(fn($get) => ! $get('city_id')),


SelectFilter::make('city_id')
    ->label('Şehir')
    ->relationship('city', 'name')
    ->indicator('Şehir')
    ->searchable()
    ->preload(),
SelectFilter::make('district_id')
    ->label('İlçe')
    ->relationship('district', 'name')
    ->indicator('İlçe')
    ->searchable()
    ->preload(),
SelectFilter::make('city_id')
    ->label('Şehir')
    ->relationship('city', 'name')
    ->indicator('Şehir')
    ->searchable()
    ->preload(),
SelectFilter::make('district_id')
    ->label('İlçe')
    ->relationship('district', 'name')
    ->indicator('İlçe')
    ->searchable()
    ->preload(),
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

Modify SelectFilter query based on another SelectFilters value (Dependent Filters)
FilamentFFilament / ❓┊help
3y ago
How to change SelectFilter indicator
FilamentFFilament / ❓┊help
3y ago
Dinamically update options based on another input
FilamentFFilament / ❓┊help
2y ago