© 2026 Hedgehog Software, LLC

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

How to get name instead of id in a select with relationship

Scenario: Select dependent that should be disabled based on the name of the other.

Forms\Components\Select::make('foo_id')
    ->live()
    ->relationship(name: 'foo', titleAttribute: 'name')
    ->required(),

Forms\Components\Select::make('bar_id')
    ->disabled(fn (Forms\Get $get): bool => ???? )),
Forms\Components\Select::make('foo_id')
    ->live()
    ->relationship(name: 'foo', titleAttribute: 'name')
    ->required(),

Forms\Components\Select::make('bar_id')
    ->disabled(fn (Forms\Get $get): bool => ???? )),
`

Is it possible to retrieve the name chosen in the first select component instead of the ID?

I know I can do get the record on DB based on Id and then get the namesomething like that based on id, but at first it seems like this information is already available on the first select, so I want to save this query to retrieve the name.
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

Show name instead of id in Select relationship field, upon record soft deletion.
FilamentFFilament / ❓┊help
2y ago
Get relationship in select
FilamentFFilament / ❓┊help
3y ago
Change case of relationship name field in a select
FilamentFFilament / ❓┊help
3y ago
How to get record of select relationship automatically
FilamentFFilament / ❓┊help
3y ago