F
Filament2mo ago
gg

Auto Select Issue in Select Option

when I try to auto select of cityids and it working well but it can also select value after auto selected.so that can cause duplicate Select::make('country_id') ->label('Country') ->reactive() ->required() ->placeholder('Please select a country') ->preload() ->searchable() ->options(Country::pluck('name', 'id')) ->afterStateUpdated(function ($state, Set $set) { if ($state) { $cities = City::where('country_id', $state)->pluck('id')->toArray(); $set('city_ids', $cities); } ), Select::make('city_ids') ->label('City') ->placeholder('Please select your cities) ->multiple() ->preload() ->searchable() ->reactive() ->options(function (Get $get) { $country_id = $get('country_id'); if ($country_id) { return City::where('country_id', $countryId)->pluck('name', 'id'); } return []; }),
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?