我将创建一个方法来删除一些在表中分类的用户,这是我的方法删除
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>
但是当我执行路径索引时,会发布此错误
我想创建一个方法来删除一些在表中分类的用户,这是我的方法。删除公共函数deletetAction(User $ user){if(!$ user){throw $ this-> ...
salt
的某些值在数据库中为空。因此,您应该在呈现链接之前进行检查。{% if user.salt|length %}
<a href="{{ path('delete_User', {
'salt': user.salt
}) }}" class="glyphicon glyphicon-pencil">delete</a>
{% endif %}