php - Sonata Admin: How to represent a Many to Many in the edit form when the associated entity has thousands of records? -
in entities, have many many relationship between roles , users
/** * @orm\manytomany(targetentity="user", mappedby="roles") */ protected $users;
in edit form role
entity i'd able see users role, , add , remove users too, added users
field in configureformfields
protected function configureformfields(formmapper $formmapper) { $formmapper ->add('name') ->add('description') ->add('users'); }
the problem sonata's approach naive: render form, executes 1 query retrieve fields of role, 1 retrieve fields of users role, , 1 retrieve fields of all users in database!!!
as have more 20,000 users in database, uses more 250mb of memory.
is there way instruct sonata show paginated list search or that?
could pcdummy/ajaxcompletebundle of interest? have stumbled upon today.
and suggest creating separate intermediate users_roles entity (and admin it). then, using sonata_type_collection, can add group:usergroups field group admin. remember not include group
field in usersgroupadmin
form config.
Comments
Post a Comment