0

preferred_choicesエンティティ フォームで使用したい:

public function buildForm(FormBuilderInterface $builder, array $options) {
    $builder->add('id','entity', array(
        'class'=>'GameShelf\UsersBundle\Entity\OwnState',
        'property' => 'name',
        'attr' => array('class'=>'chzn-select selectBig', 'data-placeholder'=>'Mam...'),
        'label' => ' ',
        'empty_value' => '',
        'preferred_choices' => array($options['selected'])
    ));
}

public function getDefaultOptions(array $options) {
    return array(
        'data_class' => 'GameShelf\UsersBundle\Entity\OwnState',
        'selected' => 1
    );
}

しかし、それはエラーを返します: Warning: spl_object_hash() expects parameter 1 to be object, integer given. 私の間違いはどこですか?

4

1 に答える 1

0

getDefaultOptions() で (int)1 を完全なエンティティ オブジェクトに置き換えてみてください

( https://github.com/symfony/symfony/pull/5277 )

于 2013-01-23T13:04:49.437 に答える