0
在cakephp中,我有一個使用參數和回調的搜索功能。我的問題是,我想用一個參數調用這個函數,但函數在調用時不能接受參數。在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
目前尚不清楚你到底在找什麼。它是否像你提交POST請求,然後將POST數據轉換爲GET?這對我來說並不合適。 –
我認爲它的另一種方式,如果你使用的是重定向,而不是它如何發佈請求,並且你的重定向代碼中還有一個額外的',' – Indrajit
使用這個插件來正確實現PRG模式https:// github。 com/FriendsOfCake/search – burzum