Esempio n. 1
0
 /**
  * Creates a new Anuncios entity.
  *
  */
 public function newAction(Request $request)
 {
     $anuncio = new Anuncios();
     $animal = new Animales();
     $user = new User();
     $anuncio->setUser($this->getUser());
     $animal->setAnuncio($anuncio);
     $anuncio->setAnimal($animal);
     $form = $this->createForm('AnunciosBundle\\Form\\AnunciosType', $anuncio);
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $em->persist($anuncio);
         $em->flush();
         return $this->redirectToRoute('anuncios_show', array('id' => $anuncio->getId()));
     }
     return $this->render('anuncios/new.html.twig', array('anuncio' => $anuncio, 'form' => $form->createView()));
 }
 /**
  * {@inheritDoc}
  */
 public function setAnuncio(\AnunciosBundle\Entity\Anuncios $anuncio = NULL)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setAnuncio', [$anuncio]);
     return parent::setAnuncio($anuncio);
 }