0

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 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.