`statePath` and `visible` nested components not working together

I have something like this:
$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'),
]);
In the database, I have a table with a JSON column called someAttribute. The idea is that the column saves the JSON dictionary of the components. Something like:
{{'1' : 'what'}, {'3' : 'ever'}}
{{'1' : 'what'}, {'3' : 'ever'}}
But, when using statePath, the components are not showing. When statePath is removed, the components do show, but are not registered as a dictionary and instead only the last modified component get saved.
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server