2012-03-06 61 views
0

我有一個搜索控制器,將查找值,並根據應顯示報告的類型呈現的具體意見。發生了一件奇怪的事情。當我發出$ this-> render時,報告視圖不會呈現。 「抓所有的」 重定向行總是被渲染...代碼如下:CakePHP的2.0控制器渲染沒有工作,所有的時間

公共職能admin_printReport(){

if (isset($this->request->data['Reports'])) { 

    $nons = $this->request->data['Reports']; 

    $res = array(); 

    // lets lookup the noncons.....  
    foreach ($nons as $dat=>$vdat) { 

     // skip the ones that are not checked 
     if ($vdat == 0) { 
      continue; 
     } 

     // this is the temporary array that holds all of the selected report numbers   >    $res[] = $dat; 

    } 

    $this->loadModel('Noncon');  
    $this->Noncon->recursion = 0; 
    $results = $this->Noncon->find('all', array('conditions'=>array('Noncon.id'=>$res))); 
    $this->set('results', $results); 

    // lets do the selection now... 
    if (isset($this->request->data['PS'])) { 
     // Print summary 
     $this->render('summary', 'print'); 
    } elseif (isset($this->request->data['PD'])) { 
     // Print detail 
     $this->render('detail', 'print'); 
    } elseif (isset($this->request->data['PDH'])) { 
     // Print detail with history 
     $this->render('detailhistory', 'print'); 
    } 
} 

// catch all if the render does not work.... 
$this->redirect(array('controller'=>'noncons', 'action'=>'search','admin'=>true)); 

}

什麼想法?

回答

1

我只是想通了......

對於每個$ this-> render,添加return。例如:

return $ this-> render('summary','print');

0

我剛剛添加了類似的問題。

在一個控制器,一個具有AJAX提交,但是沒有提交渲染。

$this->render($viewName, 'ajax'); 

使用return並沒有幫助。

的問題是,我加入

$this->render('add'); 

在控制器結束後,雖然因爲控制器的名字是添加沒有必要和autoRender爲默認值(true自動渲染視圖與控制器的相同名稱)。

希望這可以幫助別人。