Twig error - varibale does not exist for Sonata Ad

2019-08-21 09:13发布

问题:

I am passing query results to my twig view but it can't find that varibale.

It' Sonata Admin details view with multiple tabs.

Tamplate is renderig and when I pass a string it renders but when I try to call query builder with "getTransactions" it throws:

Variable "card" does not exist.

Code:

 $card = $this->getCardTransactions();

    $showMapper->tab('Card transactions')
                    ->add('Data', 'date', array(
                        'template' => "@AdminTemplates/details.html.twig",
                        'card' => $card
                    ))
                    ->end()
                ->end()

And simple as that in my twig:

{% for c in card %}
    <tr>
      <td>{{ c.name }}</td>
      <td>{{ c.title }}</td>
    </tr>
{% endfor %}#}