Guest User

MovieController

a guest
Oct 4th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.82 KB | None | 0 0
  1. public function addAction(Request $request)
  2.     {
  3.         $form = $this->createForm(MoviePersonForm::class);
  4.  
  5.         $form->handleRequest($request);
  6.  
  7.         if($form->isSubmitted() && $form->isValid())
  8.         {
  9.             $movie = new Movie();
  10.             $movie['name'] = $form['movie_name']->getData();
  11.             $movie['year'] = $form['movie_year']->getData();
  12.             $movie['description'] = $form['movie_description']->getData();
  13.  
  14.             $em = $this->getDoctrine()->getManager();
  15.             $em->persist($movie);
  16.             $em->flush();
  17.  
  18.             $this->addFlash('success', 'Movie created');
  19.  
  20.             return $this->redirectToRoute('cms_list_movie');
  21.         }
  22.  
  23.         return $this->render('cms/movie/crew.html.twig',[
  24.             'MoviePersonForm' => $form->createView()
  25.         ]);
  26.     }
Add Comment
Please, Sign In to add comment