어떻게 둘 이상의 매개 변수를 전달하는 다른 동작으로 리디렉션 할 수 있습니까? 이 코드 : URL에심포니 2 매개 변수로 리디렉션
$this->redirect('input/new?year=' . $year . '&month=' . $month);
결과 :
http://.../input?year=2009&month=9
어떻게 둘 이상의 매개 변수를 전달하는 다른 동작으로 리디렉션 할 수 있습니까? 이 코드 : URL에심포니 2 매개 변수로 리디렉션
$this->redirect('input/new?year=' . $year . '&month=' . $month);
결과 :
http://.../input?year=2009&month=9
음, 정상적인 경우 "리디렉션"하여 절대 URL로 리디렉션합니다. 당신은 할 수 있습니다 :
$this->redirect($this->generateUrl('default', array('module' => 'input',
'action' => 'new', 'year' => $year, 'month' => $month)));
나는이 더 정상적인 심포니 동작입니다 생각합니다. 라우팅 규칙을 정의 했습니까?
$this->redirect('module/action?'.http_build_query($paramsArray));
아니, 그게 도움이되지 않습니다 – kipelovets
이상한 일이 :
당신이 시도했다. 합니까$this->redirect('@default?module=input&action=new&year=' . $year . '&month=' . $month);
당신을 위해 일합니까?
네, 그 또한 작동합니다. 고마워,하지만 xarch의 솔루션은 =) – kipelovets
또한 경로 이름과 매개 변수 배열 지정, 리디렉션을 사용할 수 있습니다
$this->redirect('route_name', array('year' => $year, 'month' => $month));
(심포니 1.4에서 테스트)
현재 지원에서을 Symfony 버전 (2.7 이상) it's even easier :
return $this->redirectToRoute('default', array('year' => $year, 'month' => $month));
도움이 귀엽다. "http : //.../input/new/year/2009/month/10"과 같은 URL을 생성합니다. – kipelovets
경로가 정의되어 있으면 'default'를 이름으로 대체하고 두 번째 매개 변수를 변경할 수 있습니다 필요한 경우 경로의 매개 변수로 – xarch
경로를 정의했다면 실제로'$ this-> redirectToRoute ('routename', [ 'param1'=> 'value', [ 'param2'=> 'value'])' – chteuchteu