Advertisement
Guest User

Untitled

a guest
May 6th, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.69 KB | None | 0 0
  1.     public function addAction(Request $request)
  2.     {
  3.         $post = new Post();
  4.  
  5.         $form = $this->createFormBuilder($post)
  6.             ->add('title', 'text')
  7.             ->add('text', 'text')
  8.             ->add('date', 'date')
  9.             ->add('save', 'submit')
  10.             ->getForm();
  11.  
  12.         $form->handleRequest($request);
  13.  
  14.         if($form->isValid()) {
  15.             $em = $this->getDoctrine()->getManager();
  16.             $em->persist($post);
  17.             $em->flush();
  18.             return new Response('Dodanie do bazy');
  19.         }
  20.         return $this->render('DudekmBlogBundle:Default:form.html.twig', array(
  21.             'form' => $form->createView()
  22.         ));
  23.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement