© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
4 replies
Eugen Pașca

SelectFilter search in multiple columns - Is this intended

Hello,

I am working on a resource where i am looking into filtering and i found out that a SelectFilter can't searech in multiple columns. The clasic User having
first_name
first_name
and
last_name 
last_name 

Is this an intended functionality?

As seen bellow, i replicated that functionality using a Filter with a Select inside but it looks like too much trouble for just a simple search in multiple columns
Am i thinking of this the wrong way? Should we improve on the filter? What you thing?

   Filter::make('custom_creator_id')
            ->form([
                Select::make('creator_id')
                    ->label('Agent 22')
                    ->searchable(['first_name', 'last_name'])
                    ->relationship('creator', 'first_name')
                    ->getOptionLabelFromRecordUsing(fn(User $record) => $record->full_name),
            ])
            ->query(fn(Builder $query, array $data): Builder => $query
                ->when(
                    $data['creator_id'],
                    fn(Builder $query, $creatorId): Builder => $query->where('creator_id', $creatorId),
                )),

        SelectFilter::make('creator_id')
            ->label('Agent')
            ->searchable() // Here accept only a boolean or a Closure - the closure should return a boolean
            ->relationship('creator', 'first_name')
            ->getOptionLabelFromRecordUsing(fn(User $record) => $record->full_name),
   Filter::make('custom_creator_id')
            ->form([
                Select::make('creator_id')
                    ->label('Agent 22')
                    ->searchable(['first_name', 'last_name'])
                    ->relationship('creator', 'first_name')
                    ->getOptionLabelFromRecordUsing(fn(User $record) => $record->full_name),
            ])
            ->query(fn(Builder $query, array $data): Builder => $query
                ->when(
                    $data['creator_id'],
                    fn(Builder $query, $creatorId): Builder => $query->where('creator_id', $creatorId),
                )),

        SelectFilter::make('creator_id')
            ->label('Agent')
            ->searchable() // Here accept only a boolean or a Closure - the closure should return a boolean
            ->relationship('creator', 'first_name')
            ->getOptionLabelFromRecordUsing(fn(User $record) => $record->full_name),
Solution
Not sure whether it's intended. I think it just wasn't needed yet, so nobody implemented it. General recommendation is to use a virtual column on your DB for full_name
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

How to search in multiple fields in v3 SelectFilter?
FilamentFFilament / ❓┊help
3y ago
search for foreign key using multiple columns
FilamentFFilament / ❓┊help
3y ago
SelectFilter Not Filtering when Multiple
FilamentFFilament / ❓┊help
2y ago