F
Filamentβ€’6mo ago
Akram

Hi guys πŸ‘‹I want to make cascade drop down list from database or api dynamicaly in filamentphp

Hi guys πŸ‘‹ I want to make cascade drop down list from database or api dynamically in filamentphp Anyone has any idea how #cascade_dropdown_list #api #filamentphp
2 Replies
Povilas K
Povilas Kβ€’6mo ago
If you meant parent-child dropdowns, here's one of my examples:
Forms\Components\Select::make('country_id')
->live()
->label('Country')
->dehydrated(false)
->options(Country::pluck('name', 'id')),
Forms\Components\Select::make('city_id')
->required()
->label('City')
->placeholder(fn (Forms\Get $get): string => empty($get('country_id')) ? 'First select country' : 'Select an option')
->options(function (Forms\Get $get): Collection {
return City::where('country_id', $get('country_id'))->pluck('name', 'id');
}),
Forms\Components\Select::make('country_id')
->live()
->label('Country')
->dehydrated(false)
->options(Country::pluck('name', 'id')),
Forms\Components\Select::make('city_id')
->required()
->label('City')
->placeholder(fn (Forms\Get $get): string => empty($get('country_id')) ? 'First select country' : 'Select an option')
->options(function (Forms\Get $get): Collection {
return City::where('country_id', $get('country_id'))->pluck('name', 'id');
}),
Povilas K
Povilas Kβ€’6mo ago
No description
Want results from more Discord servers?
Add your server