0
我在DB,cards
和comments
兩個表。我有我的CakePHP應用程序啓動並運行。當卡view.ctp ..相關的評論出現在頁面的底部。CakePHP的預先填充相關記錄的外鍵
我想點擊添加新的評論,但明確將其添加爲當前的卡如預填卡領域,以顯示當前類別。
這是我目前鑑於新評論鏈接:
<?php
echo $this->Html->link(__('New comment'), array('controller' => 'comments','action' => 'add'));
?>
這是我新增評論控制器:
public function add() {
if ($this->request->is('post')) {
$this->Comment->create();
if ($this->Comment->save($this->request->data)) {
$this->Session->setFlash(__('The comment has been saved'));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The comment could not be saved. Please, try again.'));
}
}
$cards = $this->Comment->Card->find('list');
$this->set(compact('cards'));
}
我如何拿到卡設置爲當前卡爲新增評論?
我也希望能夠增加新的註釋,但與空白卡..準備好用戶,如果從列表中選擇。
輝煌的感謝! – curtisp