SHARE
TWEET

Untitled

a guest Sep 17th, 2019 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3.  
  4.     /**
  5.      * @Route("/admin/article/create" , name="admin.post.new")
  6.      */
  7.     public function new( Request $request){
  8.  
  9.         $post = new Post() ;
  10.         $post->setAutheur($this->getUser());
  11.         $form =   $this->createForm(PostType::class ,$post);
  12.         $form->handleRequest($request);
  13.  
  14.         if ($form->isSubmitted() && $form->isValid() ){
  15.             $this->em->persist($post);
  16.             $this-> em->flush();
  17.             $this->addFlash('succes' , 'Bien! Créé avec succès');
  18.             return $this->redirectToRoute('admin.post.index');
  19.         }
  20.         return $this->render('admin/posts/new.html.twig', [
  21.             "post" => $post ,
  22.             "form" => $form->createView()
  23.         ]);
  24.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top