0
votes

when I try to update one of my entites, I get this exception:

UndefinedMethodException: Attempted to call method "bindRequest" on class "Symfony\Component\Form\Form" in /Applications/MAMP/htdocs/Seotool/src/Seotool/MainBundle/Controller/TaskController.php line 64.

edit Action:

/**
@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());

}

What's wrong with my code?

1

1 Answers

1
votes

Because there is no method bindRequest. The exception is quite explicit. If you check the official API, I suppose you want to use handleRequest