Symfony2 & Twig : display all fields and keys

Viewed 15563

I have a problem with Symfony2 and Twig: I don't know how to display all fields of my entity which is loaded dynamically. Here is my code (displays nothing!!)

Controller :

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 %}
4 Answers
Related