© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
3 replies
AbderrahmenBns

CheckBoxList relationships error

When i add relationships in creating checkBoxList like shown in the code below :
Forms\Components\CheckboxList::make('speakers')
                ->relationship('speakers', 'name')
                ->options(Speaker::all()->pluck('name', 'id'))
                ->required() ,
Forms\Components\CheckboxList::make('speakers')
                ->relationship('speakers', 'name')
                ->options(Speaker::all()->pluck('name', 'id'))
                ->required() ,

This error occure :
❌ Filament\Forms\Components\CheckboxList::getRelationship(): Return value must be of type ?Illuminate\Database\Eloquent\Relations\BelongsToMany, Illuminate\Database\Eloquent\Relations\HasMany returned
Capture.PNG
Solution
Hi,

you don't need to have following if you are using relationship

->options(Speaker::all()->pluck('name', 'id'))
->options(Speaker::all()->pluck('name', 'id'))


Also the relationship must me
BelongsToMany
BelongsToMany
instead of
HasMany
HasMany
on the relation (model)
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

CheckboxList description with relationships
FilamentFFilament / ❓┊help
3mo ago
CheckBoxList
FilamentFFilament / ❓┊help
3y ago
CheckboxList Grouping
FilamentFFilament / ❓┊help
3y ago
Morph CheckboxList
FilamentFFilament / ❓┊help
3y ago