/** * Creates a new Event entity. * * @Route("/events/inscription/{id}/new", name="inscription_event_create") * @Method("POST") * @Template("AppBundle:Events:newInscription.html.twig") * @param Event $event * @param Request $request * @return array|\Symfony\Component\HttpFoundation\RedirectResponse */ public function createAction(Event $event, Request $request) { if ($event->getOpen()) { $inscription = new Inscription(); $form = $this->createForm(new InscriptionType(), $inscription, array('action' => $this->generateUrl('inscription_event_create', array('id' => $event->getId())), 'method' => 'POST')); $form->add('submit', 'submit', array('label' => 'S\'inscrire')); $form->handleRequest($request); if ($form->isValid()) { $inscription->setEvent($event); $em = $this->getDoctrine()->getManager(); $em->persist($inscription); $em->flush(); return $this->redirect($this->generateUrl('inscription_event', array('id' => $event->getId()))); } return array('inscription' => $inscription, 'form' => $form->createView()); } }