2013-01-23 53 views
0

我想在我的實體形式使用preferred_choices的Symfony2 - 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。我的錯誤在哪裏?

回答