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

1

15

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?

Leveller answered 16/9, 2015 at 7:23 Comment(0)
V
1

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.

Vignette answered 23/9, 2015 at 13:2 Comment(3)
"entity" is only for doctrine / "model" is the equivalent for propel propelorm.org/Propel/cookbook/symfony2/…Leveller
Well there it says 'index_property' => 'slug' /** If you want to use a specifiq unique column for key to not expose the PK **/ . Did you try that, as well?Vignette
as it is said, it's for the key column > i'm searching the right config for the display, not the key - BTW, this bugs occurs only with the "group_by" option, it works fine otherwiseLeveller

© 2022 - 2024 — McMap. All rights reserved.