Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Propel form type model w. group_by is rendered without property display

Env: Symfony2 2.7 / Propel 1.6

I've created a choice form type like that:

    $builder->add('mychoice', 'model', array(
            'class' => 'Foo\\Bar',
            'query' => FooBarQuery::create()->filterBySomething(true),
            'group_by' => 'example',
            'property' => 'title',
            'multiple' => false,
            'expanded' => false,
        ));

The rendering choice list is ok with good optgroup select options but the title's property is not displayed - id's property instead. If I remove the group_by option, the title property is well displayed.

What's wrong?

like image 577
Lionel Avatar asked Sep 16 '15 07:09

Lionel


1 Answers

Would this work?

   $builder->add(
        'mychoice',
        'entity',
        array(              
            'class' => 'Foo\\Bar',
            'choice_label' => 'title',
            'multiple' => false,
            'expanded' => false,
        )
    );

Set the type to entity and add a choice_label property and the property you want to be displayed.

like image 124
George Irimiciuc Avatar answered Sep 23 '22 17:09

George Irimiciuc