Closed vyshkant closed 4 years ago
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
PHP version
Subject
I have a problem with filters in the overridden MediaAdmin class.
I want to disable the output of the 'context' filter by default, but I do not want to completely abandon the logic of the base class
Sonata\MediaBundle\Admin\ORM\MediaAdmin
.The current logic of
Sonata\MediaBundle\Admin\ORM\MediaAdmin
class allows you to select one of the two:So there is no way to let 'context' filter be available in the list of the filters (not disabled) and at the same time be not expanded.
Steps to reproduce
I have overridden the MediaAdmin class, which is providing the Media admin page, to my own:
Next I've created the
Overridden\Sonata\MediaBundle\Admin\MediaAdmin
class extending from the defaultSonata\MediaBundle\Admin\ORM\MediaAdmin
class:Here overridden the
getPersistentParameters
method to override some parameters. Specifically, I did two things:null
(to disapply the 'default' filter action)hide_context
property totrue
to hide the expanded 'context' filter.Expected results
I expected the 'context' filter will be hidden (won't be expanded, but will be still available in the 'Filters' dropdown menu). The keyword
hide_context
makes me think that the 'context' filter should be hidden.Actual results
In the fact the 'context' filter was completely disabled (became unavailable in the 'Filters' dropdown menu).
Possible causes
I think this is caused by the fact, that the
show_filter
property of the$filterOptions
parameter of theSonata\AdminBundle\Datagrid\DatagridMapper::add
method is always being set to aboolean
value, whereasnull
value gives us the expected result.As we can see, the
show_filter
is always being set to eithertrue
orfalse
(which mean 'to be shown expanded' or 'to be disabled'), but never being set tonull
(which means 'to be neither expanded nor disabled').I'm not sure if this is a bug of SonataMediaBundle or SonataAdminBundle.