Update Checkboxes when select something

Hey, I have a Select with strings as options and checkboxes. When I select a specific string I want to filter out all checkboxes that are not compatible with the string. How Can I do this inside a form?
1 Reply
GeRaged | Niklas
GeRaged | NiklasOP15mo ago
// In getComponents() method
$attributes = Attribute::whereAllowsModel(Resort::class)->get();
$data = $attributes->groupBy('group')->where('group', //HERE I WANT THE OUTPUT OF THE SELECT)->map(function ($item) {
return $item->pluck('name', 'id')->toArray();
});

// Inside the form schema of the getComponents() method

Section::make('Group')
->schema([
Select::make('query')
->label('Group')
->options(Attribute::whereAllowsModel(Resort::class)->select('group')->distinct()->get()->map(fn ($value) => $value['group']))
->searchable()
->afterStateUpdated(function ($state, callable $get, callable $set) {
// HERE I WANT TO UPDATE THE CHECKBOXES BELOW FILTERED BY THE HERE SELECTED GROUP
})
]),
Section::make('Attribute')
->schema(
$data->map(fn ($attributes, $group) =>
CheckboxList::make($group)
->options($attributes)
->visible())->toArray()
)
->columns(3)
// In getComponents() method
$attributes = Attribute::whereAllowsModel(Resort::class)->get();
$data = $attributes->groupBy('group')->where('group', //HERE I WANT THE OUTPUT OF THE SELECT)->map(function ($item) {
return $item->pluck('name', 'id')->toArray();
});

// Inside the form schema of the getComponents() method

Section::make('Group')
->schema([
Select::make('query')
->label('Group')
->options(Attribute::whereAllowsModel(Resort::class)->select('group')->distinct()->get()->map(fn ($value) => $value['group']))
->searchable()
->afterStateUpdated(function ($state, callable $get, callable $set) {
// HERE I WANT TO UPDATE THE CHECKBOXES BELOW FILTERED BY THE HERE SELECTED GROUP
})
]),
Section::make('Attribute')
->schema(
$data->map(fn ($attributes, $group) =>
CheckboxList::make($group)
->options($attributes)
->visible())->toArray()
)
->columns(3)
Want results from more Discord servers?
Add your server