1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
$annonce = new Annonce();
$formDepotAnnonce = $this->createFormBuilder($annonce)
->add('departement', 'entity', array(
'class' => 'TUA\EntitiesBundle\Entity\Departement',
'empty_value' => 'Département'))
->add('ville', 'text')
->add('categorie', 'entity', array(
'class' => 'TUA\EntitiesBundle\Entity\Categorie',
'empty_value' => 'Catégorie'))
->add('titre', 'text')
->add('description', 'text')
->add('prix', 'text')
->add('commission', 'text')
->getForm();
$formDepotAnnonce->handleRequest($request);
if ($formDepotAnnonce->isValid()) {
$user = $this->getUser();
$annonce->setUser($user);
if ($request->get("validate") != null) {
$em = $this->getDoctrine()->getManager();
$em->persist($annonce);
$em->flush();
return $this->redirect($this->generateUrl('index'), 301) ;
}
return $this->render('TUAAnnonceBundle:DeposerAnnonce:deposer_annonce2.html.twig', array('annonce' => $annonce, 'formDepotAnnonce' => $formDepotAnnonce->createView()));
}
return $this->render('TUAAnnonceBundle:DeposerAnnonce:deposer_annonce.html.twig', array('formDepotAnnonce' => $formDepotAnnonce->createView())); |
Partager