你好,下面是我的模特
<?php
class Orm_demo_model extends DataMapper{
var $table= 'orm_demo';
var $has_many=array('post_model');
var $validation =array(
'name'=>array(
'label'=>'Name',
'rules'=>array('required','trim'),
),
'description'=>array(
'label'=>'Description',
'rules'=>array('required','trim'),
)
);
}
//End Of Orm_demo .php model ..
这是我的控制器
<?php
class OrmCtrl extends CI_Controller{
function __construct() {
parent::__construct();
}
function index(){
$data['title']='Add data';
$this->template->load('templates/template','ormDemoForm',$data);
}
function save(){
$obj = new Orm_demo_model();
$obj->name=$this->input->post('name');
$obj->description= $this->input->post('description');
if($obj->save()){
echo '<script>alert("Record Added..");</script>';
redirect('ormCtrl/','refresh');
}
else{
echo $obj->error->name;
echo $obj->error->description;
// echo $obj->error->string;
}
}
}
//end of ormCtrl.php file
现在的问题是,当验证失败时,它无法显示错误消息......
它返回以下消息。
Unable to access an error message corresponding to your rule name: required.
无法访问与您的规则名称对应的错误消息:required。
请告诉我,那里有什么问题..?