symfony - update field in DB symfony2 -


in application send email , when user clicks in url state of field in db change(update).

in controller have:

 public function confirmeaction($username) {     $col = $this->getdoctrine()->getrepository('acmecongebundle:collaborateur')->find($username);     echo $col->getemailcollaborateur();     $conge = $this->get('gestion_conge.congeservice')->findcongebycollaborateur($col);     $id = 2;      $conge->setetatconge($this->get('etat.etatcongeservice')->findetatbyid($id));      return $this->render('acmecongebundle:conge:confirmer.html.twig'); } 

the controller send email:

$message = \swift_message::newinstance()     ->setsubject('demande de conge sans solde')     ->setfrom($col->getemailcollaborateur())     ->setto($form->get("emailcdp")->getdata())     ->setbody($this->renderview('acmecongebundle:conge:demandecongenormal.html.twig',array('conge' => $conge )));     $this->get('mailer')->send($message); 

and demandecongenormal.html.twig contain:

{{ url('confirmer_conge' ,{'username':  id }) }} 

i id of user send email form url , want update state of entity conge when user clic on url.

i have no exception state of setetatconge doesn't change . how can update field etatfrom entity conge (conge exist in db)

at end of confirmeaction, should add:

$em = $this->getdoctrine()->getmanager(); $em->persist($conge); $em->flush(); 

to save data.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -