/** * @Route("/save", name="user_announcement_save") * @Method("POST") * @Template("HyperAdsBundle:User:Announcement/new.html.twig") */ public function createAction(Request $request) { $announcement = new Announcement(); $announcement->setAdvertiser($this->getUser()); $form = $this->createForm(new AnnouncementType(), $announcement); $form->bind($request); if ($form->isValid()) { $this->get('doctrine.orm.entity_manager')->persist($announcement); $this->get('doctrine.orm.entity_manager')->flush(); return $this->redirect($this->generateUrl('user_announcement_index')); } return array('form' => $form->createView()); }