我在add.ctp中有这个:
原文链接:https://www.f2er.com/php/133188.html<!-- File: /app/views/posts/add.ctp --> <h1>Add Post</h1> <?PHP echo $form->create('Post'); echo $form->input('title'); echo $form->input('body',array('rows' => '3')); echo $form->end('Save Post'); ?>
这在我的控制器中:
function add(){ if (!empty($this->data)) { if($this->Post->save($this->data)){ $this->Session->setFlash('Your post has been saved'); $this->redirect(array('action' => 'index')); } } }