Question

I'm using Sonata Admin as my admin backend for Symfony2, and I'm trying to load a page where my admin entity (transaction) has a many to one relationship to another entity (rate). The rate table is massive and grows very quickly, and there's not really anything I can do to change that.

When I hit the transaction list page, I get a memory sized exhausted error. Assuming this was a database problem (because the code works on my local environment), I cleared out the transaction table and the problem still happened. Once I cleared out the rates table, the page loaded immediately. I can only imagine this means that related entities are being eager-loaded on the admin pages.

Does anyone know how to force Sonata to lazy-load related entities? I've looked through the documentation and forums, and the only things I've seen either aren't relevant or say that Sonata does lazy-load automatically. Ideas?

Was it helpful?

Solution

I found the problem. Sonata may or may not lazy load, but that's not what the issue was; it was never even getting to the configureListFields() function. Instead, you don't want to add a field that has a lot of rows to your filter, it apparently loads all options at runtime.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top