FilamentF
Filament2y ago
Rome

Format state of select filter

I have a select filter with a relationship: SelectFilter::make('employee')->relationship('employee', 'name'). I need to modify de label of each option to show ID + name instead of the name only. formatStateUsing() is not available here.
Solution
->getOptionLabelFromRecordUsing(fn (Employee $record) => "{$record->id} {$record->name}")
Was this page helpful?