Symfony doctrine is not doing create / update / delete

I was working on a symfony project last month, I could CRUD data with my entities.
But now, I can’t create, update or delete a data.
I can only read data, everything is fine to read it.

When I submit a form, no error is displayed.

I tried to submit a form to create an idea. No idea is created. But when I tried to return the data json when I submit my form, the date is good, but no changes in my database.

I don’t know since when I have this problem, all these forms worked a few weeks ago.

Does anyone know why ?

Example of a route :

    /**
     * @Route("/{projet}/{id_projet}/idee/nouvelle",name="projet_idee_nouvelle")
     */
    public function projet_idee_nouvelle(int $id_projet,Request $request, ObjectManager $manager){
        $idee=new Idee();

        $repository = $this
        ->getDoctrine()
        ->getManager()
        ->getRepository('App:Projet')
        ;
        $projet=$repository->find($id_projet);

        $projets=array();
        array_push($projets,$projet);

        $form=$this->createForm(IdeeType::class,$idee, array(
            'projets'=>$projets
        ));

        $form->handleRequest($request);

        if($form->isSubmitted() && $form->isValid()){
            $manager->persist($idee);
            $manager->flush();

            //redirection on the created project
            return $this->redirectToRoute('projet_detail',array('id'=>$projet->getId()));
        }

        return $this->render('idee/idee_nouveau.html.twig',[
            'form'=>$form->createView()
        ]);
    }

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *