When you view an Admin, if that Admin has filters, there are two condition checks made which are performed to see if the display should render any filters. Where an Admin has a Default Filter, Twig checks for this, but the Admin code does not.
The issue however, is that the method hasDisplayableFilters returns true, when the inner condition checks return false. They are checking for different things.
The end result means that you end up with a data grid with no filters showing, but the container box instead. For example, my application shows:
{% set filterActive = ((filter.isActive() and filter.options['show_filter'] is null) or (filter.options['show_filter'] is same as(true))) and not admin.isDefaultFilter(filter.formName) %}
In essence, the twig filter, is checking for an addition constraint by also requiring the filter to not be a default filter.
Expected results
I'm unsure what the correct expected results here should be for Sonata. The options are either do not show default filters, or do show default filters, but both the Admin and the Twig templates need to agree which is the correct approach.
If you would like default filters to show, then you should remove the
Environment
Sonata packages
Subject
When you view an Admin, if that Admin has filters, there are two condition checks made which are performed to see if the display should render any filters. Where an Admin has a Default Filter, Twig checks for this, but the Admin code does not.
The first is in Datagrid.php https://github.com/sonata-project/SonataAdminBundle/blob/3.x/src/Datagrid/Datagrid.php#L232 Then in the twig files we have https://github.com/sonata-project/SonataAdminBundle/blob/3.x/src/Resources/views/CRUD/base_list.html.twig#L283 and https://github.com/sonata-project/SonataAdminBundle/blob/3.x/src/Resources/views/CRUD/base_list.html.twig#L293
The issue however, is that the method
hasDisplayableFilters
returns true, when the inner condition checks return false. They are checking for different things.The end result means that you end up with a data grid with no filters showing, but the container box instead. For example, my application shows:
So, the Admin.php can be boiled down too...
Whereas, the Twig conditions, it's performing
Code:
Code:
In essence, the twig filter, is checking for an addition constraint by also requiring the filter to not be a default filter.
Expected results
I'm unsure what the correct expected results here should be for Sonata. The options are either do not show default filters, or do show default filters, but both the Admin and the Twig templates need to agree which is the correct approach.
If you would like default filters to show, then you should remove the