Search code examples
phpsymfonyeasyadmin3

EasyAdmin3 static dql filters


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?


Solution

  • 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()