我在實體中發現(使用findOneBy
)單行。這裏的代碼:Symfony2 - 無法顯示實體的值
$userown = $this->getDoctrine()->getRepository('GameShelfUsersBundle:Own')
->findOneBy(array(
'game' => $game->getId(),
'user' => $em->getRepository('GameShelfUsersBundle:User')->find($session->getId())
));
現在我把它傳遞給模板爲userown
。但是,當我嘗試打印它的樹枝,用{{ userown.typo }}
,它拋出一個錯誤:
An exception has been thrown during the rendering of a template ("Catchable Fatal Error: Object of class Proxies\__CG__\GameShelf\UsersBundle\Entity\OwnState could not be converted to string in D:\!!XAMPP\htdocs\
我的實體是here。
該死,它是如此明顯,我只是忘了它;)謝謝! –