リダイレクトさせるためのコントローラのアクションでは、次のようにしている:
$this->redirect(array('controller' => 'tools', 'action' => 'index'));
または
$this->redirect('/tools/index');
また、リダイレクトでデータを渡す場合は、このようにしている:
$this->redirect('tools/index/?myArgument=12');
しかし、quot;this-redirect-array"記法で"myargument"を渡す方法を見つけることができませんでした。
ルーティングの問題があるので、これは使いたくありません:
$this->redirect(array('controller' => 'tools', 'action' => 'index', "myArgument"));
このようなものが必要です:
$this->redirect(array('controller' => 'tools', 'action' => 'index', "?myArgument=12"));
Cakeは確かに、このようにクエスチョンマークを使ったクエリ引数をサポートしている:
$this->redirect(array(
'controller' => 'tools', 'action' => 'index', '?' => array(
'myArgument' => 12
)
));
http://book.cakephp.org/2.0/en/development/routing.html#reverse-routing
でも、デスが言ったように、ただやったほうがいい:
$this->redirect(array(
'controller' => 'tools', 'action' => 'index', 'myArgument' => 12
));
これでうまくいくはずだ:
$this->redirect(array('controller' => 'tools', 'action' => 'index', 'myArgument' => 12));
CakePHP クックブック - Controller::redirect](http://book.cakephp.org/2.0/en/controllers.html#Controller::redirect) を見てみましょう。
リクエストパラメータへのアクセス を参照してください:
$this->request['myArgument'];
$this->request->myArgument;
$this->request->params['myArgument'];
これをリダイレクトに使う:
$this->redirect(array('controller' => 'tools', 'action' => 'index', 'myArgument' => 12));
また、Router::connectNamed() を router.php に追加して、セパレータを ":" から "=" に変更しました:
Router::connectNamed(
array('myArgument' => array('action' => 'index', 'controller' => 'tools')), array('default' => false, 'greedy' => false, 'separator' => '=')
);