提交表单后,$form->isValid()
验证失败。
该页面包含{{ form_widget(edit_form._token) }}
。但是当我写var_dump( $editForm->getErrorsAsString() )
时,它不输出任何东西
请问是什么原因? THX
在控制器中:
public function updateAction(Request $request, $id)
{
$em = $this->getDoctrine()->getManager('shops');
$entity = $em->getRepository('ShopAdminBundle:Goods')->find($id);
if (!$entity) {
throw $this->createNotFoundException('Unable to find Goods entity.');
}
$deleteForm = $this->createDeleteForm($id);
$editForm = $this->createEditForm($entity);
$editForm->handleRequest($request);
if ($editForm->isValid()) {
$em->flush();
return new Response("<script>window.close();</script>");
}
$qb = $em->createQueryBuilder();
$qb->select('gi')
->from('ShopAdminBundle:GoodsImage','gi')
->where('gi.gid = '.$entity->getId());
$GoodsImage = $qb->getQuery()->getResult();
return $this->render('ShopAdminBundle:Goods:edit.html.twig', array(
'entity' => $entity,
'edit_form' => $editForm->createView(),
'delete_form' => $deleteForm->createView(),
'GoodsImage' => $GoodsImage,
));
}`
并且在视图中:有字段标记和提交〜我无法上传模板代码。格式是e ..我不知道......