Haiffy
Haiffy
FFilament
Created by Dwayne on 2/20/2024 in #❓┊help
Assign an array to a Forms\Components\Select
alright thanks
25 replies
FFilament
Created by Dwayne on 2/20/2024 in #❓┊help
Assign an array to a Forms\Components\Select
thanks, however, i'm looking for way to populate the selected value automatically when opening the form, not when changing any field. this is my temporary solution
Select::make('imunization')
->multiple
->default(function () {
$imunization = [];
// first condition
$days = ... ;

if ($days <= 0) {
$imunization += ['hb0'];
}
// and many other conditions ...

return $imunization;
})
Select::make('imunization')
->multiple
->default(function () {
$imunization = [];
// first condition
$days = ... ;

if ($days <= 0) {
$imunization += ['hb0'];
}
// and many other conditions ...

return $imunization;
})
25 replies
FFilament
Created by Dwayne on 2/20/2024 in #❓┊help
Assign an array to a Forms\Components\Select
A little bit off topic, how do i dinamically add an option to be selected based on certain condition? For example, i have this select form
Forms\Components\Select::make('imuninization')
->native(false)
->multiple()
->searchable()
->options([
'hb0' => 'HB 0',
'bcg' => 'BCG',
'opv0' => 'OPV 0',
]),
Forms\Components\Select::make('imuninization')
->native(false)
->multiple()
->searchable()
->options([
'hb0' => 'HB 0',
'bcg' => 'BCG',
'opv0' => 'OPV 0',
]),
if a baby is 1 day old, then 'hb0' would be selected
25 replies