1

I have a combo with all values coming from a OneToMany relationship.

I've made a custom form here src/MySociety/Bundle/MyBundle/Form/Type/PersonRegistrationType.php

This works well.

But I want to add another value first in that combo, which says something like "Choose something here".

What is the way to do this with Symfony?

4

1 回答 1

4

拿这个例子:

        ->add('channels', 'entity', array(
                        'class' => 'MyBundle:Channel',
                        'multiple'=> false,
                        'property'=> 'label',
                        'mapped'=>false,
                        'empty_value' => "Choose a Channel",
            ))

您可以添加“空值”...我希望它可以满足您的需要...。

于 2013-10-15T08:34:12.633 回答