我有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
));
}
Run Code Online (Sandbox Code Playgroud)
detail.html.twig:
{% for key in attributes %}
<p>{{ value }} : {{ key }}</p>
{% endfor %}
Run Code Online (Sandbox Code Playgroud)