Symfony Twig变量无法识别(变量不存在)



这几个小时前还很好,我从数据库中获取数据,并简单地将其显示在Twig中的一个表中。这是控制器,我从中获得具有我的实体"的变量的实例;Cours";

/**
* @Route("/listeCours", name="liste_cours")
*/
public function index()
{
$lstCours = $this->getDoctrine()
->getRepository('App:Cours')
->findAll();
return $this->render('liste_cours/index.html.twig', ['lstCours' => $lstCours]);
}

我从存储库中为实体"保存了数据;Cours";在变量"中;lstCurs";我稍后会在这里的树枝上打电话给哪个,

{% for cours in lstCours %}
<tr>
<td>{{ cours.nom }}</td>
<td>{{ cours.type }}</td>
<td>{{ cours.description }}</td>
<td>{{ cours.prix }}</td>
<td>
<button class="btn_apt btn"><a href="">Ajouter</a></button>
</td>
</tr>

编译器不断显示异常,表示变量(lstCurs(不存在。

提前谢谢。

当你想调试你的Twig上下文时,你可以使用:

{{ dump(_context) }}

它将显示模板中所有可用的变量。

最新更新