我有Symfony2和Twig的問題:我不知道如何顯示動態加載的實體的所有字段。這裏是我的代碼(不顯示任何內容!!)Symfony2&Twig:顯示所有字段和鍵
控制器:
public function detailAction($id)
{
$em = $this->container->get('doctrine')->getEntityManager();
$node = 'testEntity'
$Attributes = $em->getRepository('TestBetaBundle:'.$node)->findOneById($id);
return $this->container->get('templating')->renderResponse('TestBetaBundle:test:detail.html.twig',
array(
'attributes' => $Attributes
));
}
detail.html.twig:
{% for key in attributes %}
<p>{{ value }} : {{ key }}</p>
{% endfor %}
好點@卡洛斯 – Mick 2012-08-02 15:38:20
謝謝!這是我的第一篇文章,我的英文不完美!它的工作原理... – user1571729 2012-08-02 15:48:36