$model = D("Academicprogramme");
if (false === $model->create()) {
$this->error($model->getError());
}
//保存当前数据对象
$list = $model->add();
if ($list !== false) { //保存成功
$this->success('新增成功!',cookie('_currentUrl_'));
} else {
//失败提示
$this->error('新增失败!');
}
}
谁帮看看为什么我的新增不能表单自动验证?
Model层
lass AcademicPorgrammeModel extends Model{
//定义主表
protected $tableName='academicprogramme';
// 自动验证设置
protected $_validate=array(
array('opAcademicYear','require','請選擇課程學年!'),
array('dprtId','require','請選擇學系!'),
array('dgrId','require','請選擇學位!'),
array('prgrId','require','請選擇學科!'),
array('opIdent','require','請選擇學科!'),
array('opIdent','','標識已經存在!',0,'unique',self::MODEL_INSERT),
);
//字段設置
protected $fields = array(
'opId', 'opAcademicYear', 'opIdent', 'dprtId','dgrId','prgrId','opCDT','_pk' => 'opId', '_autoinc' => true
);
}
为什么 啥都没有填 也插入成功,都没有经过验证过滤
最佳答案