Checkbox list groups

Anyone has an idea how to render multiple groups of checkboxes? For example, I have grouped permissions. Like Posts permissions (read, write, delete), Categories permissions (read, write, delete) and etc. And all selected checkboxes should save to BelongsToMany pivot table. I know I can make it work with handleRecordCreate, but maybe there is a Filament way?

Ex.
Fieldset::make(__('Leidimai'))
                            ->columnSpanFull()
                            ->columns(1)
                            ->visible(fn (Get $get) => (int) $get('role_id') === Role::ADMIN)
                            ->schema(
                                PermissionGroup::all()->map(function (PermissionGroup $group) {
                                    return CheckboxList::make('permissions')
                                        ->label($group->name)
                                        ->relationship('permissions')
                                        ->columns(3)
                                        ->options($group->permissions->mapWithKeys(fn (Permission $permission) => [$permission->id => $permission->name]));
                                })->toArray(),
                            ),
Was this page helpful?