2012-06-01 21 views

回答

1

對於您的觀點你無法創建文件:

Error: Confirm you have created the file: /home/100141468/public_html/comp2084/todo/app/View/Employees/view.ctp 

更改您的視圖代碼看起來像:

$this->set('employee', $this->Employee->read(null, $id)); 

你的觀點會像任何你想要的,隨便用HTML標記您需要顯示數據,無論是表格,div,列表等。在您的視圖中,您將有$employee變量可用,請使用debug($employee);查看其內容。

例:<div><b>Name:</b> <?php echo $employee['Employee']['name']; ?></div>

您可能還需要檢查記錄第一的存在是爲了重定向到前一頁,讓用戶知道該記錄不存在(設置提示信息)。

爲您刪除,您通過GET訪問,但不允許它在你的代碼:

if ($this->request->is('get')) { 
    throw new MethodNotAllowedException(); 
} 

如果你想通過訪問網址中刪除/employees/delete/{id}刪除代碼塊。

+0

我不確定你在說什麼刪除...你能告訴我代碼的外觀。 –

+0

哈哈沒關係,謝謝:)只是想通了你的意思! –

+0

還有一個問題,如果視圖在控制器中看起來正確,view.ctp的代碼是什麼? –