sonata_type_model using ajax to autocomplete?

1,132 views
Skip to first unread message

ShadowShade

unread,
Jun 18, 2014, 10:12:06 AM6/18/14
to sonata...@googlegroups.com

Hi, I was wondering if i could get some advice on the best approach to do the below :-

using 'sonata_type_model' to allow relating entities which looks good, but it loads in all the possible values to a hidden select field which is queried against for the autocomplete.

unfortunately the live table will have thousands of records so was wondering if anyone has ever ajaxified the autocompleter, or if there is something in place already? if not im guessing the best approach would be to copy whats there and create a new 'sonata_type_model_ajax'

any advice or pointers would be greatly appreciated :)

Raphael Schumacher

unread,
Jun 26, 2014, 4:25:17 AM6/26/14
to sonata...@googlegroups.com
It's currently not supported out of the box, but it's an ongoing discussion, e.g. see https://github.com/sonata-project/SonataAdminBundle/pull/1764.

There are examples however which you can make use of in your case: FOSUserBundle has implemented autocomplete in fields for choosing a user (where there could be thousands of users, as well). Among others parts, one of the key elements is the UserToUsernameTransformer class used for this purpose.

Hope this helps, regards RAPHAEL

Thomas Rabaix

unread,
Jun 26, 2014, 4:41:55 AM6/26/14
to sonata...@googlegroups.com
Hello,

 You can use the sonata_type_model_list as a solution to avoid loading to many entities.


--
You received this message because you are subscribed to the Google Groups "sonata-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonata-users...@googlegroups.com.
To post to this group, send email to sonata...@googlegroups.com.
Visit this group at http://groups.google.com/group/sonata-users.
For more options, visit https://groups.google.com/d/optout.



--
Thomas Rabaix
http://rabaix.net | http://sonata-project.org

Neophyte

unread,
Jun 27, 2014, 9:32:49 AM6/27/14
to sonata...@googlegroups.com
Thanks for the links :) sonata_tyoe_model_autocomplete looks promising
Reply all
Reply to author
Forward
0 new messages