Closed mmucklo closed 4 years ago
Can you provide a PR with a fix @mmucklo ?
@core23 any clue where I should begin looking?
Maybe have a look at this PR where the feature was introduced https://github.com/sonata-project/SonataAdminBundle/pull/4059
I just added the following:
On Load
{% if admin.isDefaultFilter(filter.formName) %}
<div class="panel panel-default">
<div class="panel-body">
<b>Default filter</b> {{ filter.options.placeholder }}
- <a href="#" class="sonata-toggle-filter sonata-ba-action" filter-target="filter-{{ admin.uniqid }}-{{ filter.name }}" filter-container="filter-container-{{ admin.uniqid() }}">
<i class="fa {{ (filter.isActive() or filter.options['show_filter']) ? 'fa-check-square-o' : 'fa-square-o' }}"></i>{{ filter.label|trans({}, filter.translationDomain ?: admin.translationDomain) }}
</a> <span class="text-muted">(edit)</span>
</div>
</div>
{% endif %}```
Can you provide a PR if you find a solution @Kalyse
Hi @mmucklo Just in case you haven't found a solution yet. I had the same problem and just added the filter values directly inside the $datagridValues variable instead of set them inside configureDefaultFilterValues method. Then the filters will show up in the filters section and can be removed (except for the checkboxes in the example but thats another problem with checkboxes in filters which do not have a third state).
Note: This is a workaround. I don't know if this will work in the future but for now it seems to help a lot.
Example:
protected $datagridValues = array( 'name' => array ('type' => EqualType::TYPE_IS_EQUAL, 'value' => 'ipsum lorem'), 'is_verified' => array ('type' => EqualType::TYPE_IS_EQUAL, 'value' => true), 'is_locked' => array ('type' => EqualType::TYPE_IS_EQUAL, 'value' => false), 'is_active' => array ('type' => EqualType::TYPE_IS_EQUAL, 'value' => true), '_page' => 1, '_sort_order' => 'ASC', '_sort_by' => 'another_nr', );
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Environment
Sonata packages
Symfony packages
Subject
A Default filter is not easily removable.
1) Overrode configureDefaultFilterValues(...) in an Admin class. 2) Added a default filter with ChoiceType::TYPE_NOT_CONTAINS
Documentation says class is ChoiceFilter::TYPE_.... but there's no constant in that class https://sonata-project.org/bundles/admin/master/doc/reference/action_list.html
3) Filter works as expected, however, I'm unable to easily remove it as all I see is a blank filter section when loaded (see screen capture)
Steps to reproduce
See above
Expected results
A way to remove the filter
Actual results
No apparent way to remove the filter