© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
2 replies
Jordy ten Elsen

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
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
getSearchResultsUsing
but that feels like a workaround.

Thank you in advance!
image.png
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

Select field with relationship - exclude current record from options
FilamentFFilament / ❓┊help
3y ago
How to exclude all option from select filter
FilamentFFilament / ❓┊help
3y ago
Pivot Select using Relationship
FilamentFFilament / ❓┊help
2w ago
hasOne model relationship select list options
FilamentFFilament / ❓┊help
3y ago