0
如何從蛋糕php中的窗體(視圖)中的文本框到控制器檢索值?從窗體(視圖)中的文本框中檢索值到蛋糕php中的控制器
如何從蛋糕php中的窗體(視圖)中的文本框到控制器檢索值?從窗體(視圖)中的文本框中檢索值到蛋糕php中的控制器
這裏有保存模型數據從CakePHP的書爲例:
function edit($id) {
//Has any form data been POSTed?
if(!empty($this->data)) {
//If the form data can be validated and saved...
if($this->Recipe->save($this->data)) {
//Set a session flash message and redirect.
$this->Session->setFlash("Recipe Saved!");
$this->redirect('/recipes');
}
}
//If no form data, find the recipe to be edited
//and hand it to the view.
$this->set('recipe', $this->Recipe->findById($id));
}
如果你的模型是食譜,和你輸入被命名爲「冠軍」,則該值將在$ this->數據[「食譜」] [「標題」],如果您設置您的看法,像這樣:
echo $this->Form->create('Recipe');
echo $this->Form->hidden('id');
echo $this->Form->input('title');
echo $this->Form->end('Save Recipe');
所以,請看這裏:http://book.cakephp.org/view/1031/Saving-Your-Data
並嘗試做博客教程,它可以幫助你得到starte d:http://book.cakephp.org/view/1528/Blog
您是否在問如何處理控制器中POST數據的基本問題?這是基本的基本的東西;您將盡最大努力閱讀遍佈谷歌的CakePHP文章的介紹。另外檢查Cake手冊。在發佈這樣的問題之前,請花點功夫爲自己弄點事情。 – 2010-06-15 18:09:35