Published in: PHP
URL: http://www.symfonylab.com/how-to-populate-object_select_tag-with-your-own-objects/
Sometimes you need to have an ability to show limited number of elements in your select objects or sort elements by name or so. I figured out that this feature was added to objectselecttag later so that not everybody knows about that. This feature’s name is ‘peermethod’ - effectively you create your peer method which returns objects which must appear in your objectselecttag. So here is the code for objectselect_tag:
‘related_class’ => ‘Object’, ‘peer_method’ => ‘getSortedObject’, ‘control_name’ => ‘object_id’, ‘include_blank’ => true, )); in your ObjectPeer.php: $c = new Criteria(); $c->addAscendingOrderByColumn(TablePeer::NAME); $rs = TablePeer::doSelect($c); return $rs; } and in your yml generator: fields: departement_id: { params: text_method =getNomCode peer_method =doSelectOrderByCode }
Comments
Subscribe to comments
You need to login to post a comment.

That's a fine example though i found this feature somehow. But if i want to load grouped options then how can i do it with admin generator.