F
Filamentβ€’14mo ago
buzkall

Wrong indicator in SelectFilter with multiple and translatable

Using the latest version (3.0.82) I'm having an issue with the filter indicator if I use the multiple option. With single select filter, the indicator is shown in the active locale, but the multiple one, it shows the json
->filters([
Tables\Filters\SelectFilter::make('gender')
->multiple()
->preload()
->relationship('gender', 'name')
->getOptionLabelFromRecordUsing(fn($record) => $record->name),

Tables\Filters\SelectFilter::make('maritalStatus')
->preload()
->relationship('maritalStatus', 'name')
->getOptionLabelFromRecordUsing(fn($record) => $record->name),
->filters([
Tables\Filters\SelectFilter::make('gender')
->multiple()
->preload()
->relationship('gender', 'name')
->getOptionLabelFromRecordUsing(fn($record) => $record->name),

Tables\Filters\SelectFilter::make('maritalStatus')
->preload()
->relationship('maritalStatus', 'name')
->getOptionLabelFromRecordUsing(fn($record) => $record->name),
No description
4 Replies
ahmant
ahmantβ€’13mo ago
Same issue here. Did you solve it?
buzkall
buzkallOPβ€’13mo ago
no, I've opened and issue in github
ahmant
ahmantβ€’13mo ago
Try this:
->filters([
SelectFilter::make('majors')->relationship('majors', 'title')
->getOptionLabelFromRecordUsing(fn ($record) => $record->title) // πŸ‘ˆ
])
->filters([
SelectFilter::make('majors')->relationship('majors', 'title')
->getOptionLabelFromRecordUsing(fn ($record) => $record->title) // πŸ‘ˆ
])
buzkall
buzkallOPβ€’12mo ago
The snippet you gave me is for the option labels I'm talking here to the indicators in the table, which can be solved using something like this in each filter (which doesn't need to be done if the filter is not multiple)
->indicateUsing(fn(array $data): ?string => $data ?
__('Gender') . ': ' . Gender::whereIn('id', $data['values'])->pluck('name')->join(', ') :
null),
->indicateUsing(fn(array $data): ?string => $data ?
__('Gender') . ': ' . Gender::whereIn('id', $data['values'])->pluck('name')->join(', ') :
null),
Want results from more Discord servers?
Add your server