使用form_validation 报错
版本 2.2.0使用form_validation 后 报错 Message: Use of undefined constant required - assumed 'required'
源码如下:
public function add($page='add'){
if (! file_exists(APPPATH.'/views/type/'.$page.'.php')) {
show_404();
}
$this->load->helper('form');
$this->load->library('form_validation');
$this->form_validation->set_rules('typeName','分类名称',required);
if ($this->form_validation->run() === FALSE) {
$data['title'] = '添加分类';
$this->load->view('templates/header',$data);
$this->load->view('type/add.php');
$this->load->view('templates/footer');
}else{
$this->type_model->insert_type();
$data['title'] = '分类名称列表';
$this->load->view('templates/header',$data);
$this->load->view('type/list');
$this->load->view('templates/footer');
}
}
$this->form_validation->set_rules('typeName','分类名称',required); 改成
$this->form_validation->set_rules('typeName','分类名称', 'required');
写代码要仔细。
页:
[1]