当我尝试更新我的一个entites时,我得到了这个例外:
UndefinedMethodException:尝试在/Applications/MAMP/htdocs/Seotool/src/Seotool/MainBundle/Controller/TaskController.php第64行中的“Symfony \ Component \ Form \ Form”类上调用方法“bindRequest”。
编辑动作:
/**
@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());
}
我的代码出了什么问题?