这是我的模型-->
<?php
class Post extends AppModel {
public $validate = array(
'title' => array(
'rule' => 'alphaNumeric',
'required' => true,
'message' => 'Alphabets and numbers only'
),
'body' => array(
'rule' => 'notEmpty'
)
);
}
?>
控制器 -->
public function add() {
if ($this->request->is('post')) {
$this->Post->create();
if ($this->Post->save($this->request->data)) {
$this->Session->setFlash('Your post has been saved.');
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash('Unable to add your post.');
}
}
}
并查看 -->
<h1>Add Post</h1>
<?php
echo $this->Form->create('Post');
echo $this->Form->input('title');
echo $this->Form->input('body', array('rows' => '3'));
echo $this->Form->end('Save Post');
?>
我怎样才能让它工作。我跟着他们在 cakephp.org 上提供的 cakephp 书,做的和那里提到的完全一样,然后也做错了