[英]An exception has been thrown during the rendering of a template (“Unable to resolve dependency [Parameter #0 [ $listing ]]”)
[英]An exception has been thrown during the rendering of a template (“Parameter ”salt“ for route ”delete_User“ must match ”[^/]++"
我會創建一個方法來刪除一些在表中分類的用戶這是我的方法刪除
public function deletetAction(User $user)
{
if (!$user) {
throw $this->createNotFoundException('No user found');
}
$em = $this->getDoctrine()->getEntityManager();
$em->remove($user);
$em->flush();
return $this->redirectToRoute('index_User');
}
我在我的觀點中稱這個方法為 index.html.twig
<tbody>
{% for user in useres %}
<tr>
<td> {{user.username}} </td>
<td> {{user.email}} </td>
<td> {{user.date(user.LastLogin)}}</td>
<td> {{user.enabled}} </td>
<td class="center hidden-400">
<a href="{{ path('delete_User', {'salt':user.salt }) }}"class="glyphicon glyphicon-pencil">delete </a>
</td>
<td>{{user.roles[0]}}</td>
</tr>
{% endfor %}
</tbody>
但是當我執行路由索引時,會發布此錯誤
可能,您的字段salt
的某些值在數據庫中為空。 因此,您應該在呈現鏈接之前進行檢查。
{% if user.salt|length %}
<a href="{{ path('delete_User', {
'salt': user.salt
}) }}" class="glyphicon glyphicon-pencil">delete</a>
{% endif %}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.