사용자가 요청을 시작한 경로로 다시 리디렉션하고 싶습니다.Symfony2 : 요청 된 경로로 리디렉션
예 : /프로필
/프로필/편집
/프로필
OR :
/제품
/프로필/편집
/제품
이 리디렉션 모드로 설정해야하는 항목은 무엇입니까?
사용자가 요청을 시작한 경로로 다시 리디렉션하고 싶습니다.Symfony2 : 요청 된 경로로 리디렉션
예 : /프로필
/프로필/편집
/프로필
OR :
/제품
/프로필/편집
/제품
이 리디렉션 모드로 설정해야하는 항목은 무엇입니까?
편집 페이지로 GET 매개 변수 (예 : redirectTo
)로 리디렉션 경로를 전달할 수 있으며 편집 프로세스가 완료되면 해당 경로로 리디렉션 할 수 있습니다.
return new RedirectResponse($request->query->get('redirectTo');
매개 변수가 제공되는지 여부를 확인하여 더 강력하게 만들 수 있으며, 그렇지 않은 경우 기본 경로로 리디렉션 할 수 있습니다.
/profile/edit
컨트롤러의 경우 $request->headers->get('referer')
으로 페이지를 캡처 할 수 있습니다.
/profile/edit
이 단일 양식의 페이지 인 경우 리디렉션이 있어야하는 위치를 나타내는 숨겨진 필드를 추가하는 것이 좋습니다.
public function editAction(Request $request)
{
// If you have a POST value coming from the user, it will be used, otherwise
// assume this is the first time they landed on the page and grab the current
// referer. With this method it doesn't matter how many times they submit the form
// you won't accidentally overwrite the referer URL with /profile/edit. That could
// lead to a confusing loop.
$referer = $request->request->get('referer', $request->headers->get('referer'));
if ($formIsSaved)
{
return new RedirectResponse($referer)
}
return array(
// Your template should include a hidden field in the form that returns this.
'referer' => $referer,
);
}
안녕, 나는 GET 매개 변수 : 세션이 같은 것을 사용할 수 없습니다와 장난하지 않도록 하시겠습니까? – bodokaiser
세션과 관련하여 매우 지저분해질 것입니다. –
다른 솔루션? – bodokaiser