示例#1
0
 /**
  * Creates a new Produits entity.
  *
  */
 public function newAction(Request $request)
 {
     $produit = new Produits();
     $transFr = new Traductions();
     $transFr->setLangue('fr');
     $transFr->setProduit($produit);
     $produit->addTraduction($transFr);
     $transEn = new Traductions();
     $transEn->setLangue('en');
     $transEn->setProduit($produit);
     $produit->addTraduction($transEn);
     $form = $this->createForm(new ProduitsType(), $produit);
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $em->persist($produit);
         $em->flush();
         return $this->redirectToRoute('produits_show', array('id' => $produit->getId()));
     }
     return $this->render('produits/new.html.twig', array('produit' => $produit, 'form' => $form->createView()));
 }
 /**
  * Creates a form to delete a Traductions entity.
  *
  * @param Traductions $traduction The Traductions entity
  *
  * @return \Symfony\Component\Form\Form The form
  */
 private function createDeleteForm(Traductions $traduction)
 {
     return $this->createFormBuilder()->setAction($this->generateUrl('traductions_delete', array('id' => $traduction->getId())))->setMethod('DELETE')->getForm();
 }