I need to filter the results of an index page by default so that it only returns entities that meet a certain condition, without the user actively filtering anything. EasyAdminBundle2 documentation seems to have an answer with static filters. However, I can't seem to find the option in EasyAdminBundle3. Is it possible?
Asked
Active
Viewed 313 times
2 Answers
0
I can't comment yet so i use the answer instead : You can use
public function configureFields(string $pageName): iterable
{
return [
AssociationField::new('randomField'),
TextField::new('randomField2'),
/////////
}
public function configureCrud(Crud $crud): Crud
{
return $crud
->setDefaultSort(['id' => 'DESC'])
;
}
In this example, ->setDefaultSort will sort by default the id of your item by DESC.

Cephalopodius
- 117
- 1
- 10
-
Thank you, but that would sort records, and wont filter them – CHE6yp Sep 02 '21 at 12:28
0
As stated in the easyadmin 2 -> 3 migration guide (https://symfony.com/doc/current/bundles/EasyAdminBundle/upgrade.html)
The dql_filter option to quickly filter the entity listings has been removed. Instead, use the createIndexQueryBuilder() method in the CRUD controller.
There is also a related SO question with code examples: Symfony EasyAdminBundle 3 override the createIndexQueryBuilder()

skymeissner
- 228
- 1
- 9