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

Andreoween's avatar

Filament`s CheckboxList does not display selected items when editing

Code:

Forms\Components\CheckboxList::make('powers')
                    ->relationship(name: 'powers', titleAttribute: 'title')
                    ->columns(2)
                    ->label('Powers')
                    ->columnSpanFull()
                    // ->afterStateHydrated(static function ($component, $state) {
                    //     Log::info('Checkbox state hydrated: ' . print_r($component, true));
                    // })
                    ->required(),

I tried the afterStateHydrated method, but it didn’t help, and there was no clear answer in the documentation either.

No ideas yet, maybe someone has already encountered a similar problem. I will be glad to answer :)

0 likes
7 replies
jaseofspades88's avatar

Have you correctly declared your powers relationship on your model?

Andreoween's avatar

@jaseofspades88 Power model

    public function contactPeople()
    {
        return $this->belongsToMany(ContactPerson::class, 'power_company_contact_people', 'power_id', 'company_contact_people_id');
    }

And ContactPeople model

    public function powers()
    {
        return $this->belongsToMany(Power::class, 'power_company_contact_people');
    }
Andreoween's avatar

@jaseofspades88 Yes

I forgot to say it actually ContactPeopleRelationManager, no classic resource.

PS

Now i try use Select with multiple method, but it dont work too, when editing, items dont selected. It work in filament demo very well

demo.filamentphp.com/shop/products/products/1/edit

jaseofspades88's avatar

I can't make bricks without clay. Just guessing with lack of code examples you put up and I probably won't come back to this thread again. This is well documented, you're missing something simple. Go back to the documentation and follow it. Everything documented on Filament is documented well, so if you're doing it wrong, it's because the problem is between your chair and the keyboard.

1 like

Please or to participate in this conversation.