F
Filamentβ€’5d ago
Reka

togglebutton group information

hello team, I read the docs, but I still not have the right behaviour I want with filament I created a filament page, with a form filled, and I want to group my items by sort of information In other words, I have an array which contains another array in it, and I would like to split my array into 2 defined groups
return $form
->schema([
ToggleButtons::make('Orientations') // https://www.laravel-filament.cn/docs/en/3.x/forms/fields/toggle-buttons
->options($orientations)
->inline()
->label('Orientations')
->live()
])
->statePath('data');
}
return $form
->schema([
ToggleButtons::make('Orientations') // https://www.laravel-filament.cn/docs/en/3.x/forms/fields/toggle-buttons
->options($orientations)
->inline()
->label('Orientations')
->live()
])
->statePath('data');
}
It works well if my $orientations array is flat : [1 => 'first', 2=>'second', 3=>'third']; but I would like to split my array [1 => ['A', 'B', 'C'], 2 => ['Z', 'Y', 'X']] Do you have any idea to do this easily ? Thank you for your help πŸ™‚
4 Replies
toeknee
toekneeβ€’5d ago
Hmm, not sure I follow? You have a single toggle what are you trying to do in the afterStatEU[dated since you are not sending those functions I am a little unsure.
Reka
RekaOPβ€’5d ago
I put my complete code, but only ->options() is interesting in that case. I changed the initial sourcecode to avoid confusion
toeknee
toekneeβ€’5d ago
Right, that's just not possible. As it stands the nesting of the options is single level. For what you want, you probably want to manipluate the data and build a toggle for each of the split arrays.
Reka
RekaOPβ€’5d ago
yes, it is what I supposed. Thanks, I just wanted to be sure it wasn't another option to do that. I put my question as resolved πŸ™‚

Did you find this page helpful?