Default options of checkbox list
I have this section :
How can I compare the current checkbox id with the User resource role id to make it checked ?
Section::make()
->schema([
Forms\Components\Repeater::make('academies')
->label('academies')
->relationship('academies')
->schema([
Forms\Components\TextInput::make('title')
->label('title')
->disabled(),
Forms\Components\CheckboxList::make('roles')
->label('roles')
->options(function ($record) {
return $record->roles->pluck('name', 'id')->toArray();
})
->formatStateUsing(function ($record) use ($form) {
$userRoleIds = $form->model->roles->pluck('id')->toArray();
$currentCheckBoxId = //ID
return in_array($currentCheckBoxId,$userRoleIds);
})
])
->addable(false)
->columns(1),
])
->columnSpan([
'sm' => 2,
]),Section::make()
->schema([
Forms\Components\Repeater::make('academies')
->label('academies')
->relationship('academies')
->schema([
Forms\Components\TextInput::make('title')
->label('title')
->disabled(),
Forms\Components\CheckboxList::make('roles')
->label('roles')
->options(function ($record) {
return $record->roles->pluck('name', 'id')->toArray();
})
->formatStateUsing(function ($record) use ($form) {
$userRoleIds = $form->model->roles->pluck('id')->toArray();
$currentCheckBoxId = //ID
return in_array($currentCheckBoxId,$userRoleIds);
})
])
->addable(false)
->columns(1),
])
->columnSpan([
'sm' => 2,
]),How can I compare the current checkbox id with the User resource role id to make it checked ?