Sonata type collection with a lot (very very much) of relations

1,840 views
Skip to first unread message

Imanol Cea Gonzalez

unread,
Oct 30, 2013, 5:07:44 AM10/30/13
to sonata...@googlegroups.com
Hi, i have large entities with many relations, so the admin class it's ver very slow (in case it doesn't fail because of memory limits). I have configureFormFields like this:
        ->add('users', 'sonata_type_collection', array(
            'cascade_validation' => true,
            'required' => false,
                ), array(
            'edit' => 'inline',
            'inline' => 'table',
            'admin_code' => 'simbiotica.calp.admin.organization_user'
        ))
My question is. Is there other way of representing relations in the form? I would like only a list of related entities and a link to edit it. Maybe i'm wrong, but i think its loading the whole entity to only represent a few fields and it's eating the memory.
Thanks!

Jakala

unread,
Oct 30, 2013, 1:30:14 PM10/30/13
to sonata...@googlegroups.com
hello:


you can make your own type field form... Or, if not, you can do something like this:

   ->add('users', null, array('template' => "mybundle::mytemplate.html.twig"))

with this, your field now use the mytemplate.html.twig template to render. You must create this template and write, for example, name & link...

bruno roux

unread,
Oct 30, 2013, 4:52:16 PM10/30/13
to sonata...@googlegroups.com
I think using a custom template wouldn't solve the issue of huge memory consumption or loading time because every single object still has to be hydrated by doctrine.

I think the best option here is to limit the dataset using parent / child admin classes.
Take a look at what is done in sonata news bundle : https://github.com/sonata-project/SonataNewsBundle the 2 admin classes define a parent / child relationship.

Don't know if it impacts perfs, but using sonata_type_model_list instead of sonata_collection where applicable might be useful too.
Reply all
Reply to author
Forward
0 new messages