How to exclude current relationship options from Select input using->relationship()?

Select::make('role_ids')
->label('Gebruikersrollen')
->columnSpan(2)
->multiple()
->options(Role::all()->pluck('name', 'id')),
Select::make('role_ids')
->label('Gebruikersrollen')
->columnSpan(2)
->multiple()
->options(Role::all()->pluck('name', 'id')),
The above code snippet works if I manually set the role_ids property at the model. But using the relationship method it does not:
Select::make('roles')
->label('Gebruikersrollen')
->columnSpan(2)
->multiple()
->preload()
->relationship('roles', 'name'),
Select::make('roles')
->label('Gebruikersrollen')
->columnSpan(2)
->multiple()
->preload()
->relationship('roles', 'name'),
As you can see in the screenshot, the role 'Hoofdgebruiker' is selected but still listed as option. Is this intended or how can this be solved? I know I can probably fix it using getSearchResultsUsing but that feels like a workaround. Thank you in advance!
2 Replies
Dan Harrin
Dan Harrin14mo ago
its actually a bug that we are unable to fix at the moment
Jordy ten Elsen
Jordy ten Elsen14mo ago
GitHub
BelongsToManyMultiSelect displays already attached options in dropd...
Package filament/filament Package Version v2.12.2 Laravel Version v9.11.0 Livewire Version No response PHP Version PHP 8.1.4 Bug description When using the BelongsToManyMultiSelect component, alrea...