public function addAction($facture_id) { $em = $this->get('doctrine.orm.entity_manager'); $facture = $em->getRepository('TrezLogicielTrezBundle:Facture')->find($facture_id); $object = new Tva(); $object->setFacture($facture); $form = $this->get('form.factory')->create(new TvaType(), $object); if ('POST' === $this->get('request')->getMethod()) { $form->handleRequest($this->get('request')); if ($form->isValid()) { $this->get('doctrine.orm.entity_manager')->persist($object); $this->get('doctrine.orm.entity_manager')->flush(); $this->get('session')->getFlashBag()->set('success', "La tva a bien été ajoutée"); return new RedirectResponse($this->generateUrl('tva_index', array('facture_id' => $facture_id))); } } return $this->render('TrezLogicielTrezBundle:Tva:add.html.twig', array('form' => $form->createView())); }
/** * Add tvas * * @param \Trez\LogicielTrezBundle\Entity\Tva $tvas * @return Facture */ public function addTva(\Trez\LogicielTrezBundle\Entity\Tva $tvas) { $tvas->setFacture($this); // added because we're the inverse side $this->tvas[] = $tvas; return $this; }