Ejemplo n.º 1
0
 /**
  * @Route("/edit/{slug}", name="evento_edit")
  * @ParamConverter("workshop", class="AppBundle:Workshop")
  * @Template()
  * @param Request $request
  * @param Workshop $workshop
  * @return array
  */
 public function editAction(Request $request, Workshop $workshop)
 {
     $response = new Response(null, 200);
     $form = $this->createForm("register_workshops_form_type", new UpdateWorkshop($workshop), ["action" => $this->generateUrl("evento_edit", ["slug" => $workshop->getSlug()]), "method" => "POST"]);
     if ($request->isMethod("POST")) {
         $form->handleRequest($request);
         if ($form->isValid()) {
             $this->get("tactician.commandbus")->handle($form->getData());
             $this->addFlash("success", "Edycja się udała ;)");
             $this->redirectToRoute("evento_show", ["slug" => $workshop->getSlug()]);
         } else {
             $response->setStatusCode(400);
         }
     }
     return $this->render("AppBundle:Default:edit.html.twig", ["form" => $form->createView()], $response);
 }