Table text filter not showing indicator

I have the following table filter:
Tables\Filters\Filter::make('project')
->form([
Forms\Components\TextInput::make('name')
])
->query(function ($query, array $data) {
return $query->when($data['name'], function ($query, $name) {
return $query->where('name', 'like', '%' . $name . '%');
});
})
Tables\Filters\Filter::make('project')
->form([
Forms\Components\TextInput::make('name')
])
->query(function ($query, array $data) {
return $query->when($data['name'], function ($query, $name) {
return $query->where('name', 'like', '%' . $name . '%');
});
})
The filter works but no indicator shows in the filter section nor on the filter badge count. I just want to make sure I'm doing this right before opening an issue. Thanks.
Solution:
I looked into it and it's not a bug per se... Filter by default is a checkbox form component which means it either has an active or inactive state. Think is_visible or is_featured. The default indicator for this default state is to use the label() or indicator(). However, if you add a custom form field to this Filter, it then expects it to have indicateUsing() to show the filter. I've made a PR to clarify the docs: https://github.com/filamentphp/filament/pull/7889...
GitHub
[Docs] Clarify using a custom indicator with filter forms by archil...
Using indicator() to define an active indicator doesn't work with custom filter forms. This adds a clarifying sentance so devs know to use indicateUsing() to show an active indicator.
Jump to solution
3 Replies
Kenneth Sese
Kenneth Sese16mo ago
Seems like it's a bug. It works with using ->indicateUsing(), but it should default to using label and then indicator, but neither of those two seem to be working, just ->indicateUsing(). Since I'm looking at filters right now, I'll take a look in a bit and submit a PR if I can find the problem and fix it.
Solution
Kenneth Sese
Kenneth Sese16mo ago
I looked into it and it's not a bug per se... Filter by default is a checkbox form component which means it either has an active or inactive state. Think is_visible or is_featured. The default indicator for this default state is to use the label() or indicator(). However, if you add a custom form field to this Filter, it then expects it to have indicateUsing() to show the filter. I've made a PR to clarify the docs: https://github.com/filamentphp/filament/pull/7889
GitHub
[Docs] Clarify using a custom indicator with filter forms by archil...
Using indicator() to define an active indicator doesn't work with custom filter forms. This adds a clarifying sentance so devs know to use indicateUsing() to show an active indicator.
Brian Kidd
Brian KiddOP16mo ago
Thanks @kennethsese I appreciate you looking into it. Planning to get Filter Sets after making a little more progress.
Want results from more Discord servers?
Add your server