FilamentF
Filament3y ago
HL

Filter value=null error after refreshing page

I have a simple filter in my Resource's table:
return $table
...
->filters([
                SelectFilter::make('service')
                    ->placeholder('All')
                    ->options([
                        1 => 'Account',
                        2 => 'Custom Leveling',
                    ])
                    ->native(false),
            ])
...


I open the resource table from the url:
http://127.0.0.1:8000/admin/all-orders

This sql query runs:
select * from `all_orders` order by `id` desc limit 10 offset 0


All good.

Now I set the filter once to something
http://127.0.0.1:8000/admin/all-orders?tableFilters[service][value]=1
I refresh the page, still all good

Than delete the filter, and get to this url:
http://127.0.0.1:8000/admin/all-orders?tableFilters[service][value]=null

I refresh, and no result are shown and this sql query is run:
select count(*) as aggregate from `all_orders` where (`service` = 'null')


The service is always an integer, can't be null.

Is it the intended way for the url query to switch to null, in case I delete the filter?
I noticed, that this isn't the case when I never refresh the site, that is what's causing the problem.
Solution
This is a known issue with Livewire v3. Filament Issue here: https://github.com/filamentphp/filament/issues/7129

At the bottom there is a workaround you can implement in the meantime.
GitHub
Package filament/filament Package Version v3 Laravel Version v9.19 Livewire Version v3 PHP Version PHP 8.1 Problem description In v3 when you select a filter, the query string will then populate wi...
Was this page helpful?