Slim 3 withRedirect问题及参数
Slim 3 withRedirect problem and parameters
我使用 Slim 3,我想将值传递给 withRedirect
$app->get('/users/create/', function($request, $response, $args) use ($user){
return $this->view->render($response, 'usuarios/crear.html', ['data'=> []]);
})->setName('root');
然后我重定向
return $response->withRedirect($this->router->pathFor('root', ['data'=> $input]));
并重定向但未显示新数据。感谢阅读!
pathFor()
方法的第二个参数用于具有命名占位符的路由,如 /users/{id}
。
pathFor($name, array $data = [], array $queryParams = [])
的3.参数为查询参数。
例子
return $response->withRedirect($this->router->pathFor('root', [], ['data'=> $input]));
我使用 Slim 3,我想将值传递给 withRedirect
$app->get('/users/create/', function($request, $response, $args) use ($user){
return $this->view->render($response, 'usuarios/crear.html', ['data'=> []]);
})->setName('root');
然后我重定向
return $response->withRedirect($this->router->pathFor('root', ['data'=> $input]));
并重定向但未显示新数据。感谢阅读!
pathFor()
方法的第二个参数用于具有命名占位符的路由,如 /users/{id}
。
pathFor($name, array $data = [], array $queryParams = [])
的3.参数为查询参数。
例子
return $response->withRedirect($this->router->pathFor('root', [], ['data'=> $input]));