-1
我有一個問題,這裏是項目:問題與重定向的symfony
-> An user answer to a Quizz in POST
-> It submits his answers
-> Calls a controller to flush the POST results
-> Return the user to the homepage (this is the problem, I would like the user to be redirected to that Quizz to see the results).
/**
* Finds and displays a quizz entity.
*
* @Route("/quizz/{id}", name="quizz_answer")
* @Method({"GET", "POST"})
*/
.....
return $this->render('quizz/repondre.html.twig', array(
'quizz' => $quizz,
'nbrrep' => $questions,
'arrayquest' => $arrayQuestions,
'delete_form' => $reponseForm->createView(),
));
當用戶提交他的回答它調用:
/**
* Finds and displays a quizz entity.
*
* @Route("/awnser/", name="save_awnsers")
* @Method({"POST"})
*/
public function enregistrerReponseSequence(Request $request) {
$em = $this->getDoctrine()->getManager();
$listereponse = $request->request->all();
$user = $this->getUser();
foreach ($listereponse as $lareponse) {
$reponse = $em->getRepository("AppBundle:Reponse_Sequence")->find($lareponse);
$user->addReponsesSequence($reponse);
}
$em->flush();
return $this->render('base.html.twig');
}
<form method="POST" action="{{ path("enregistrerReponseSequence")}}" class='form-horizontal'>
我想用戶返回到該Quizz看到的結果。
我想過只是調用控制器來添加結果和刷新頁面,但我真的不知道該怎麼做。
而你的問題? –
看看路由名稱它是awnser,它應該是答案(不知道這是否會解決問題) –
@RumenPanchev這只是一個打字錯誤,因爲我改名爲一切。 – Cesar