codeigniter 2 - validation in Datamapper orm -
hello below model
<?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 ..
and controler
<?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
now problem can't show error message when validation failed...
it returns following message.
unable access error message corresponding rule name: required.
unable access error message corresponding rule name: required.
please tell me whats problem there..?
Comments
Post a Comment