2012-04-26 49 views
0
$tip->setGame($em->getRepository('XXXBundle:Game')->find($id)); 
     $form = $this->createFormBuilder($tip)->add('player', 'entity', array(
     'class' => 'XXXBundle::FootballPlayer', 
     /*'query_builder' => function(\XXX\XXXBundle\Entity\FootballPlayerRepository $er) 
     { 
      $er->findByCurteam($team->getName()); 
     },*/ 
    ))->getForm(); 

(不是真的用我的代碼「XXX」) 錯誤時:Symfony2的錯誤嘗試在表單創建實體領域

Warning: class_parents(): Class XXX\XXXBundle\Entity\ does not exist and could not be loaded in D:\www\xxx\xxx\vendor\doctrine\lib\Doctrine\ORM\Mapping\ClassMetadataFactory.php line 223

似乎實體類中找不到 - 奇怪

回答

1

你的代碼有些奇怪:'class' => 'XXXBundle::FootballPlayer',你確定::存在嗎?從來沒有見過它,似乎是一個錯誤(也許會引發錯誤)。

經過測試,是的,這是因爲雙重::取代:'class' => 'XXXBundle:FootballPlayer',

+0

謝謝,是一個愚蠢的錯字:) – jeff 2012-04-27 08:24:52