src/DEVWEB/ColocationBundle/Controller/AdvertController.php
// controller de la vue edit.html.twig
controller de la vue edit.html.twig
controller de la vue edit . html . twig
public function editAction($id, Request $request)
  {
    $em = $this->getDoctrine()->getManager();
    $advert = $em->getRepository('DEVWEBColocationBundle:Advert')->find($id);
    if (null === $advert) {
      throw new NotFoundHttpException("L'annonce d'id ".$id." n'existe pas.");
    }
    $form = $this->get('form.factory')->create(AdvertEditType::class, $advert);
    if ($request->isMethod('POST') && $form->handleRequest($request)->isValid()) {
      $em->flush();
      $request->getSession()->getFlashBag()->add('notice', 'Annonce bien modifiée.');
      return $this->redirectToRoute('devweb_colocation_view', array('id' => $advert->getId()));
    }
    return $this->render('@DEVWEBColocation/Advert/edit.html.twig', array(
      'advert' => $advert,
      'form'   => $form->createView(),
    ));
  }
public function editAction ( $ id , Request $ request ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ advert = $ em -> getRepository ( 'DEVWEBColocationBundle:Advert' ) -> find ( $ id ) ; if ( null === $ advert ) { throw new NotFoundHttpException ( " L'annonce d'id  " . $ id . "  n'existe pas. " ) ; } $ form = $ this -> get ( 'form.factory' ) -> create ( AdvertEditType :: class , $ advert ) ; if ( $ request -> isMethod ( 'POST' ) && $ form -> handleRequest ( $ request ) -> isValid ( ) ) { $ em -> flush ( ) ; $ request -> getSession ( ) -> getFlashBag ( ) -> add ( 'notice' , 'Annonce bien modifiée.') ; return $ this -> redirectToRoute ( 'devweb_colocation_view' , array ( 'id' => $ advert -> getId ( ) ) ) ; } return $ this -> render ( '@DEVWEBColocation/Advert/edit.html.twig' , array ( 'advert' => $ advert , 'form' => $ form -> createView ( ) , ) ) ; }
controller de la vue edit.html.twig
controller de la vue edit . html . twig