I need to redirect my user to CRUD index where filter "STATUS = ACTIVE" is applied.
I've this:
$url = $this->adminUrlGenerator
->setController(Customer::class)
->generateUrl();
return $this->redirect($url);
But I can't find a way to add a filter to it. I've tried searching for something like:
->setFilter('Status', 'ACTIVE')
but without any luck. There is nothing in the docs. How to do it?
EasyAdmin handle filters in your url by adding multiple options to handle each filters case.
value
to be compared withvalue2
(Example: between value and value2)comparison
for "equal", "less than", "greater than" etc...Filtering by Status ACTIVE
would modify your url with
&filters[Status][comparison]=%3D&filters[Status][value]=ACTIVE
Note that here %3D is
=
encoded for the url, but using=
would work as well.
So when using EA AdminUrlGenerator, you can use ->set
to modify options.
You would get:
$url = $this->adminUrlGenerator
->setController(Customer::class)
->set('filters[Status][value]', 'ACTIVE')
->set('filters[Status][comparison]', '=')
->generateUrl();
I kept the case on Status, but if your property is in lowercase, do it here as well.