CheckboxList (BulkToggle)

Issues with bulktoggle when depended on another field
1 Reply
BlackShadow
BlackShadowOP17mo ago
Select::make('country_id')
->required()
->reactive()
->disabledOn('edit')
->afterStateUpdated(fn(Set $set) => $set('provinces', null))
->native(false)
->options(Country::all()->pluck('name' ,'id')),

Forms\Components\CheckboxList::make('provinces')
->visible(fn($get) => $get('country_id'))
->columnSpanFull()
->searchable()
->bulkToggleable()
->columns(3)
->relationship('provinces', 'name', function ($query, $get) {
if($get('country_id')) {
return $query->where('country_id', $get('country_id'));
}
return $query;
}),
Select::make('country_id')
->required()
->reactive()
->disabledOn('edit')
->afterStateUpdated(fn(Set $set) => $set('provinces', null))
->native(false)
->options(Country::all()->pluck('name' ,'id')),

Forms\Components\CheckboxList::make('provinces')
->visible(fn($get) => $get('country_id'))
->columnSpanFull()
->searchable()
->bulkToggleable()
->columns(3)
->relationship('provinces', 'name', function ($query, $get) {
if($get('country_id')) {
return $query->where('country_id', $get('country_id'));
}
return $query;
}),
Want results from more Discord servers?
Add your server