在cakephp中,我有一个使用参数和回调的搜索功能。我的问题是我想用一个参数调用这个函数,但函数在调用时不能接受参数。
//I cant call this function with a paramater
$this->redirect(array('action' => 'email_list',$id,));
...
public function email_list($search = 0) {
$this->set( 'search',$search);
;
if (($this->request->is('post') || $this->request->is('put'))) {
if (isset($this->request->data['searchFilter'])) {
$filter_url['controller'] = $this->request->params['controller'];
$filter_url['action'] = $this->request->params['action'];
$filter_url['page'] = 1;
// for each filter we will add a GET parameter for the generated url
foreach($this->data['User'] as $name => $value){
if($value){
$filter_url[$name] = urlencode($value);
}
}
//Post params are now GET paramaters
return $this->redirect($filter_url);
}//isset
答案 0 :(得分:0)
使用在进入时被销毁的会话变量来制定解决方案。它快速而简单。必须在cakephp ver 2中重做搜索功能不是我想做的事情。我正在更新到cakephp ver 3
public function email_list($search = 0) {
if ($this->Session->check('sessrowid'))
{
$searchRowId=$this->Session->read('sessrowid');
$this->Session->delete('sessrowid');
}