Way to optimize Object relation fields ?

71 views
Skip to first unread message

sevajol...@gmail.com

unread,
Feb 22, 2013, 9:04:07 AM2/22/13
to symfony2adm...@googlegroups.com
Hi,
I'm a new user of Symfony2 Admin generator. It's very usefull !
I've search on the doc and internet but not found serious response about my question. What is the best way to optimize Objects relations fields ? An example:
i've in my backend administration of 'Group'. A group have 'Owner' (User).
In my forms (new, edit, filters) i can choose in select list who is the owner. But, with thousand Users it make a big and heavy list ^^
What is way to integrate an "ajax" field ? Or is it already coded ?
Thank's !
Bux.

loostro

unread,
Feb 26, 2013, 6:07:50 AM2/26/13
to symfony2adm...@googlegroups.com, sevajol...@gmail.com
Hi,

if you're useing DoctrineORM have a look at EntityPicker form type

see new documentation (its being rewritten so its not full, but this part is covered):

Documentation -> Form Extensions -> EntityPicker

Or direct link:

Cheers :)

B. Kausch

unread,
May 8, 2014, 4:56:20 AM5/8/14
to symfony2adm...@googlegroups.com, sevajol...@gmail.com
How can I use some sort of entity picker with the new avocode form types... I really have no idea looking at the documentation: https://github.com/avocode/FormExtensions/blob/master/Resources/doc/documentation.md

Piotr Gołębiewski

unread,
May 8, 2014, 5:13:39 AM5/8/14
to symfony2adm...@googlegroups.com
Use afe_select2_entity  -> its an extension to the entity form type (default symfony) so it inherits all the options (see symfony doc http://symfony.com/doc/current/reference/forms/types/entity.html

It also has new options, that are passed down to select2 javascript widget.. see select2 doc for the list of avaliable options: http://ivaynberg.github.io/select2/

So.. the basic idea is, entity form type expects (in POST) the unique identifier for the object. Eg. an ID. You can use the default entity form options, to create a dropdown list of ID's => NAME (useing query_builder and property options).

You can however, use some of the select2 options to load the data from another source (ajax callback).. the only thing you have to keep in mind, that the select's value sent by POST upon submiting the form, must be a uid for the object.

Pozdrawiam,
Piotr Gołębiewski
-------------------------------------------------------------------------------------------

AVOCODE Piotr Gołębiewski
Wojska Polskiego 49/20, 05-101 Nowy Dwór Mazowiecki
NIP: 524-26-09-204


2014-05-08 10:56 GMT+02:00 B. Kausch <benjami...@gmail.com>:
How can I use some sort of entity picker with the new avocode form types... I really have no idea looking at the documentation: https://github.com/avocode/FormExtensions/blob/master/Resources/doc/documentation.md

--
--
You received this message because you are subscribed to the Google
Groups "Symfony2 Admingenerator bundles support for users" group.
To post to this group, send email to
symfony2adm...@googlegroups.com
To unsubscribe from this group, send email to
symfony2admingene...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony2admingenerator?hl=en
 
---
Found bundle documentation at http://symfony2admingenerator.org/

---
You received this message because you are subscribed to a topic in the Google Groups "Symfony2 Admingenerator bundles support for users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/symfony2admingenerator/JS0il4IPUg8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to symfony2admingene...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

B. Kausch

unread,
May 9, 2014, 6:01:55 AM5/9/14
to symfony2adm...@googlegroups.com
I try hard with this post: https://github.com/avocode/FormExtensions/issues/22

But there are so many things I can't get my head around. I want to have an inital selection, but how can I get the selected entity in the choices ( http://symfony.com/doc/current/reference/forms/types/entity.html#choices ) - I have no way of knowing the id of the related entity in your getFormOption function...

B. Kausch

unread,
Sep 3, 2014, 8:26:26 AM9/3/14
to symfony2adm...@googlegroups.com
Again: " I have no way of knowing the id of the related entity in your getFormOption function..." Any help?

Piotr Gołębiewski

unread,
Sep 3, 2014, 9:33:50 AM9/3/14
to symfony2adm...@googlegroups.com

Ile give a new example when im back at home

--

Piotr Gołębiewski

unread,
Sep 4, 2014, 8:00:41 AM9/4/14
to symfony2adm...@googlegroups.com
​Hi,

you must modify the formType (eg. EditType, NewType) and in the buildForm method you can 

$myObject = $builder->getData();

since you'll be modifying the formType anway -> you can set field options directly in the buildForm OR you can pass this to your getFormOptions method

Reply all
Reply to author
Forward
0 new messages