Bonjour,
Je cherche à editer une entité mais cela bug.
Voici mon erreursi on pouvait m'aider à la déchiffrer)
Catchable Fatal Error: Argument 1 passed to Symfony\Component\Form\Form::createView() must be an instance of Symfony\Component\Form\FormView, instance of SB\UserBundle\Entity\Uzer given, called in /media/www-dev/private/symfonyz/src/SB/UserBundle/Controller/UzerGestController.php on line 66 and defined in /media/www-dev/private/symfonyz/vendor/symfony/symfony/src/Symfony/Component/Form/Form.php line 1041
Voici mon code du controleur.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
    public function editAction($id)
    {
        $uzer = new Uzer();
        $form = $this->createForm(new UzerType, $uzer);
        $repository = $this->getDoctrine()
                           ->getManager()
                           ->getRepository('SBUserBundle:Uzer');
 
        $myuzer = $repository->find($id);
        if($myuzer === null)
        {
            throw $this->createNotFoundException('Vous n\'avez pas encore ajouté d\'utilisateur');
        }
        $request = $this->get('request');
        if ($request->getMethod() == 'POST') {
          $form->bind($request);
          if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->persist($uzer);
            $em->flush();
            return $this->redirect($this->generateUrl('uzer_gest_view_user', array('id' => $uzer->getId(),'uzer'=>$uzer)));
            }
          }
        return $this->render('SBUserBundle:UzerGest:edituzer.html.twig', array('id' => $myuzer->getId(),'form' => $form->createView($myuzer)));
    }