0
當我嘗試更新我的entites之一,我得到這個異常:更新實體表單
UndefinedMethodException:試圖調用方法「bindRequest」階級「的Symfony \分量\表\表」 /應用程序/MAMP/htdocs/Seotool/src/Seotool/MainBundle/Controller/TaskController.php線路64
編輯操作:
/**
@Route(
* path = "/tasks/edit/{id}",
* name = "edit_task"
*)
* @Template()
*/
public function edit_taskAction($id, Request $request)
{
$request = $this->get('request');
if (is_null($id)) {
$postData = $request->get('task');
$id = $postData['id'];
}
$em = $this->getDoctrine()->getManager();
$task = $em->getRepository('SeotoolMainBundle:Task')->find($id);
$form = $this->createForm(new TaskType(), $task);
if ($request->getMethod() == 'POST') {
$form->bindRequest($request);
if ($form->isValid()) {
// perform some action, such as save the object to the database
$em->flush();
return $this->redirect($this->generateUrl('taskmanager'));
}
}
return array('form' => $form->createView());
}
這有什麼錯我的代碼?
謝謝,這對我有用! – Marvin 2014-08-31 14:23:09