Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * @Route("/admin/article/create" , name="admin.post.new")
- */
- public function new( Request $request){
- $post = new Post() ;
- $post->setAutheur($this->getUser());
- $form = $this->createForm(PostType::class ,$post);
- $form->handleRequest($request);
- if ($form->isSubmitted() && $form->isValid() ){
- $this->em->persist($post);
- $this-> em->flush();
- $this->addFlash('succes' , 'Bien! Créé avec succès');
- return $this->redirectToRoute('admin.post.index');
- }
- return $this->render('admin/posts/new.html.twig', [
- "post" => $post ,
- "form" => $form->createView()
- ]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement