© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
19 replies
Dimas Angga

getOptionLabelUsing is not working for custom option label result in Select

i cannot make it work using getOptionLabelUsing to make custom option label
image.png
Solution
Here you go. Try this. You'll need to adapt to your columns:

Forms\Components\Select::make('user')
    ->searchable()
    ->getSearchResultsUsing(fn (string $search): array => 
        User::where('name', 'like', "%{$search}%")
            ->limit(50)
            ->get()
            ->mapWithKeys(fn ($user) => 
                [$user->id => $user->name . ' - ' . $user->email]
            )
            ->toArray()
    )
    ->getOptionLabelUsing(function ($value): ?string {
        $user = User::find($value);
        return $user->name . ' - ' . $user->email;
    }),
Forms\Components\Select::make('user')
    ->searchable()
    ->getSearchResultsUsing(fn (string $search): array => 
        User::where('name', 'like', "%{$search}%")
            ->limit(50)
            ->get()
            ->mapWithKeys(fn ($user) => 
                [$user->id => $user->name . ' - ' . $user->email]
            )
            ->toArray()
    )
    ->getOptionLabelUsing(function ($value): ?string {
        $user = User::find($value);
        return $user->name . ' - ' . $user->email;
    }),
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
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Custom option label in multiple select
FilamentFFilament / ❓┊help
3y ago
Selected option's label does not update in select field
FilamentFFilament / ❓┊help
3y ago
Modifying the option label in Select
FilamentFFilament / ❓┊help
3y ago
AttachAction not working for custom select
FilamentFFilament / ❓┊help
3y ago