Symfony2: How to go back to a page where the request of a form was send from
doctrine, php, symfony
Solution
You could redirect for request referer:
return $this->redirect($request->headers->get('referer'));
Or even better for defined route:
return $this->redirect($this->generateUrl('your_route'));
where `your_route` is path to you `mysite/productnumber_2.html` page.
Problem
I have a link: `mysite/productnumber_2.html`. On this Site I have a formular in a twig template, the action of this form leads to `.../createAssessment`. In my controller I do things like save in a DB. My question is, how can I go back to the url `mysite/productnumber_2.html`? My function in teh controller looks like this: ``` /** * * @Route(path = "/createassessment", name="create_assessment", methods = "POST") * @param Request $request The Request object * @return RedirectResponse */ public function createAssessmentAction(Request $request) { $form = $this->createForm(new AssessmentType()); $form->handleRequest($request); if ($form->isValid()) { $assessment = $form->getData(); $em = $this->getDoctrine()->getManager(); $em->persist($assessment); $em->flush(); return $this->redirect( ## WHAT DO I HAVE TO PUT HERE?? ## ); } } ```