Skip to content
Advertisement

Symfony EasyAdminBundle 3 override the createIndexQueryBuilder()

It said on the EasyAdminBundle doc

For example, the index() action calls to a method named createIndexQueryBuilder() to create the Doctrine query builder used to get the results displayed on the index listing. If you want to customize that listing, it’s better to override the createIndexQueryBuilder() method instead of the entire index() method.

So let’s imagine I have in my user entity the field isDeleted set to true when the user is deleted. In the index page, I want to display only user with isDeleted = false. How to override the createIndexQueryBuilder() for this purpose?

Here is the method createIndexQueryBuilder

JavaScript

I tried to override it like this but it didn’t work

JavaScript

Advertisement

Answer

All you need is add entity. in where clause 🙂

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement