© 2026 Hedgehog Software, LLC

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

Trying to update Select field options when another field is updated?

Here is my code below. locations is a variable on my livewire component that contains the form schema

 Toggle::make('floridaOnly')
                        ->default(true)
                        ->reactive()
                        ->afterStateUpdated(function (Closure $set, $state) {
                            $this->locations = AlamoLocationsFormatter::getFilterOptions(
                                SearchAlamoVehicleLocations::handle()->body(), $state
                            );
                        })
                        ->columnSpan(3),
                    Select::make('fromLocation')
                        ->options($this->locations)
                        ->searchable()
                        ->required(),
 Toggle::make('floridaOnly')
                        ->default(true)
                        ->reactive()
                        ->afterStateUpdated(function (Closure $set, $state) {
                            $this->locations = AlamoLocationsFormatter::getFilterOptions(
                                SearchAlamoVehicleLocations::handle()->body(), $state
                            );
                        })
                        ->columnSpan(3),
                    Select::make('fromLocation')
                        ->options($this->locations)
                        ->searchable()
                        ->required(),


Not sure if "after state updated" is where this type of logic should go. But basically, I send the state in (true or false) and based on that i run a filter and return the locations. The locations value is being changed by this afterStateUpdated hook, but the options in the below select field "fromLocation" aren't being updated.
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

Select options not updated when using "create & create another" button
FilamentFFilament / ❓┊help
3y ago
Make CheckBoxList selected when SELECT field is updated.
FilamentFFilament / ❓┊help
2y ago
Testing select field options
FilamentFFilament / ❓┊help
3y ago
Slug field not updated when update title field
FilamentFFilament / ❓┊help
3y ago