Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Cushty's avatar
Level 4

Parent child and pivot table Filament

Hi, I have a pivot table for categories and they have parent and child relationships on the table. I wanted to use a checkbox list so a user checks children's categories and it is saved to the DB. I thought of 2 ways, the relationship in filament seems to work well but it grabs all categories regardless of parent or child, so it's one big list. I then thought maybe do each parent with just a label and then have the children's categories in a checkbox list, this works really well, but im not sure if when I get to saving it will work correctly or if I need to do something more when saving. Thanks

CheckboxList::make('clothes')
    ->label('Men\'s Clothing')
    ->options([
        'shirts' => 'Shirts',
        'pants' => 'Pants',
        'jackets' => 'Jackets',
        'suits' => 'Suits',
        'shoes' => 'Shoes',
    ])
    ->bulkToggleable()
    ->extraAttributes(['class' => 'checkbox-wrapper']),

CheckboxList::make('clothes')
    ->label('Women\'s Clothing')
    ->options([
        'dresses' => 'Dresses',
        'skirts' => 'Skirts',
        'blouses' => 'Blouses',
        'pants' => 'Pants',
        'shoes' => 'Shoes',
    ])
    ->bulkToggleable()
    ->extraAttributes(['class' => 'checkbox-wrapper']),
0 likes
0 replies

Please or to participate in this conversation.