Formatting choice list options in entity form type

121 views
Skip to first unread message

Pau Peris

unread,
Jul 2, 2012, 8:01:52 AM7/2/12
to sonata...@googlegroups.com, symf...@googlegroups.com

Hi,

i'm using Entity form type, choice based, in order to provide a choice list inside a Sonata Admin form. What i would like is to use a child property to display the collection of elements inside the choice list.

Does any one knows how to provide the label to be shown inside the chocie list or how to give format to the choice list array?

    $formMapper->add( 'frArea', 'entity', array(
        'class'             => 'myVendor\myBundleBundle\View\FrArea',
                    //When using a child property here, choice list gets corrupted/bad formatted
        'property'          => 'idArea',
        'em'                => 'formacions',
        'query_builder'     =>  function( EntityRepository $er )
                                {
                                    return $er->createQueryBuilder( 'qb' )
                                              ->add( 'select', 'a' )
                                              ->add( 'from', 'myVendor\myBundleBundle\View\FrArea a' );
                                              //->leftJoin('a.idiomes', 'ai');
                                },
        'required'          => false, 
        'label'             => ucfirst( $this->trans( 'my_label', array(), $this->translationDomain, $this->langCode ) )
) );

Reply all
Reply to author
Forward
0 new messages