2013-03-05 30 views
0

我的问题是post数据后,我怎么能刷新我的观点“search.ctp”考虑到我刚刚删除的记录。问题是以下。刷新视图我提交了一份关于删除记录

我的控制器代码

public function search() { 
    if ($this->request->is('post')) { 
     $this->set("isPost", TRUE); 
     $query = $this->data; 
     $output = $this->Question->find("all",    array("conditions"=>array("Question.lectureId"=>$query["Lecture"]["Lecture"], 
                     "Question.type"=>$query["Lecture"]["status"]))); 
     $this->set("questions", $output); 


    } else { 
     $this->LoadModel("Lecture"); 
     $outputL = array(); 
     $for = $this->Lecture->find("all", array("fields" => array("_id", "title"))); 
     foreach ($for as $key => $value) { 
      $outputL[$value["Lecture"]["_id"]] = $value["Lecture"]["title"]; 
     } 
     $this->set("lectures",$outputL); 
     // 
     $statuses = array(
      "" => "Select a question type", 
      "anonymousQuestion" => "anonymousQuestion", 
      "handUp" => "handUp", 
      "userQuestion" => "userQuestion" 
      ); 
     $this->set("statuses", $statuses); 
    } 
} 

所以下面的情况发生; 我打开视图“search.ctp”(“我的管理界面”),设置2搜索参数,可以 并使用提交按钮后的数据。然后,我的IF语句将这个语句识别为POSt并将我的查询结果返回给我。问题是,当我删除记录... 它重定向我回到我的搜索行动进入再次查询参数...我如何只刷新页面以相同的查询参数,不留我的观点。

Ø忘记了删除功能的代码:

  public function delete($id = null) { 
    if (!$this->request->is('post')) { 
     throw new MethodNotAllowedException(); 
    } 
    $this->Question->id = $id; 
    if (!$this->Question->exists()) { 
     throw new NotFoundException(__('Invalid configuration')); 
    } 
    if ($this->Question->delete()) { 
     $this->Session->setFlash(__('Question deleted')); 
    return $this->redirect(array("action"=>"search")); 
    } 
    $this->Session->setFlash(__('Question was not deleted')); 
    $this->redirect(array('action' => 'search')); 
} 

回答

1

作为一种解决办法我又函数,它与我的搜索功能与POST请求不GET请求同样的事情。基本上用查询参数返回数据。我使用会话帮助器将查询转到我的其他功能。不知道如何聪明那是,但它的伎俩我... 仍然会很高兴知道,如果有人有一个解决方案,我没有再拍功能/视图