我是cake php的初学者......我创建了页面模型等等。但是当我点击添加页面表单上的发布按钮时我的数据没有提交。下面是我的代码。任何帮助将不胜感激..这是我的控制器功能
function add(){
if(!empty($this->data)){
if($this->Page->save($this->data)){
$this->Session->setFlash('This Page was successfully added!');
$this->redirect(array('action'=>'index'));
} else {
$this->Session->setFlash('This Page was not added, Please try again!');
}
}
}
这是我的 Page.php
class Page extends AppModel {
var $name ='Page';
var $validate = array (
'title' => array(
'title_must_not_be_blank'=>array(
'rule'=> 'notEmpty',
'message'=> 'This Page is missing A Title!'
),
'title_must_no_be_unique'=>array(
'rule'=> 'isUnique',
'message'=> 'A Page with the Title exists!'
)
),
'body'=>array(
'body_must_not_be_blank'=>array(
'rule'=> 'notEmpty',
'message'=> 'This Page is missing A Body text!'
)
)
);
public function isOwnedBy($Page, $user) {
return $this->field('id', array('id' => $Page, 'id' => $user)) === $Page;
} }
这是视图/页面/add.ctp
<div id="Page">
添加新页面
<?php
echo $this->form->create('Page', array('action'=>'add'));
echo $this->form->input('title');
echo $this->form->input('body');
echo $this->form->end('Publish');
?>