$array_of_things = ['1', '2', '3'];
$array_of_components = [];
foreach ($array_of_things as $a) {
array_push(
$array_of_components,
Select::make($a)->options([
'what' => 'what',
'ever' => 'ever',
'et' => 'cetera',
])->multiple()->visible(function (Get $get) use ($a) {
return $get('componentX') == $a;
})
);
}
// ...
return $form
->schema([
Select::make('componentX')->options([
'1' => '1',
'2' => '2',
'3' => '3'
])->dehydrated(false)->live(), // This activates a component from $array_of_components
Group::make('does_not_matter')->schema($array_of_components)->statePath('someAttribute'),
]);
$array_of_things = ['1', '2', '3'];
$array_of_components = [];
foreach ($array_of_things as $a) {
array_push(
$array_of_components,
Select::make($a)->options([
'what' => 'what',
'ever' => 'ever',
'et' => 'cetera',
])->multiple()->visible(function (Get $get) use ($a) {
return $get('componentX') == $a;
})
);
}
// ...
return $form
->schema([
Select::make('componentX')->options([
'1' => '1',
'2' => '2',
'3' => '3'
])->dehydrated(false)->live(), // This activates a component from $array_of_components
Group::make('does_not_matter')->schema($array_of_components)->statePath('someAttribute'),
]);