4r1y4n

Untitled

Nov 7th, 2014
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.63 KB | None | 0 0
  1.     public function createAction(Request $request)
  2.     {
  3.         $entity = new Contact();
  4.         $form = $this->createCreateForm($entity);
  5.         $form->handleRequest($request);
  6.  
  7.         if ($form->isValid()) {
  8.            
  9.  
  10.             $em = $this->getDoctrine()->getManager();
  11.             $em->persist($entity);
  12.             $em->flush();
  13.  
  14.             return $this->redirect($this->generateUrl('contact_show', array('id' => $entity->getId())));
  15.         }
  16.  
  17.         return $this->render('ITWContactBundle:Contact:new.html.twig', array(
  18.             'entity' => $entity,
  19.             'form'   => $form->createView(),
  20.         ));
  21.     }
Advertisement
Add Comment
Please, Sign In to add comment