F
Filament2y ago
Vp

Filter form is very weird

I am using like this https://filamentphp.com/docs/2.x/tables/filters#using-a-toggle-button-instead-of-a-checkbox and below is my code
Tables\Filters\SelectFilter::make('country_id')
->relationship('country', 'name', fn (Builder $query) => $query->active()),
//...
Tables\Filters\Filter::make('is_badge')
->toggle()
->query(fn (Builder $query): Builder => $query->badge()) // if remove this fn () then filter is not working..
Tables\Filters\SelectFilter::make('country_id')
->relationship('country', 'name', fn (Builder $query) => $query->active()),
//...
Tables\Filters\Filter::make('is_badge')
->toggle()
->query(fn (Builder $query): Builder => $query->badge()) // if remove this fn () then filter is not working..
On url it added parameters ?tableFilters[is_badge][isActive]=0 and on initial (page refresh) the display is correct If i filter country and remove from X button (clear all) then the parameters are also removed, and It display only is_badge (filter is happening) You can see it from video.. sorry for bad English
Filament
Filters - Table Builder - Filament
The elegant TALL stack table builder for Laravel artisans.
7 Replies
Vp
VpOP2y ago
Version: v2.17.46
moaaz_m_f
moaaz_m_f2y ago
will the same happen if you use $query->where('badge', 1) ?
Vp
VpOP2y ago
Yes, same..
moaaz_m_f
moaaz_m_f2y ago
I think I found the issue it's in the core. go to:
vendor\filament\tables\src\Concerns\HasFilters.php
vendor\filament\tables\src\Concerns\HasFilters.php
then find a function called
(filters plural)

replace
(filters plural)

replace
$this->updatedTableFilters();
with the below function
with the below function
$this->resetTableFiltersForm();``` let me know if it works. it would be better if we add this in github issues if it's not there. take note this issue will not happen if you click the "X" next to the filter this will happen only if you try to remove all filters at once from the X button on the right side.
Vp
VpOP2y ago
I am trying to create issue in git, first let me check your method quick and will response back to you again Yes, your logic is working.. can I mention your logic in issue (for easy fixing)
moaaz_m_f
moaaz_m_f2y ago
sure please
Vp
VpOP2y ago
https://github.com/filamentphp/filament/issues/6722 submit issue.. let's hope they resolve ASAP
GitHub
problem after reset all with toggle filter · Issue #6722 · filament...
Package filament/filament Package Version latest Laravel Version latest Livewire Version latest PHP Version 8.1 Problem description When reset the filter (reset all) then error comes like below ima...
Want results from more Discord servers?
Add your server