欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

codeigniter 表单验证加载失败

程序员文章站 2024-02-04 09:49:10
...

错误提示:

codeigniter 表单验证加载失败

phpload->model('article_model', 'post');
    }
   
    public function index(){

        $this->load->view('admin/post_list.html');
    }
   
    public function add(){
        $this->load->model('category_model', 'cate');
        $data['category'] = $this->cate->fetch();
       
        $this->load->helper('form');
        $this->load->view('admin/post_add.html', $data);
    }
   
    public function save(){
        $this->load->library('form_validation', 'verify');
        $status = $this->verify->run('article');
       
        if ($status) {
            $data = array(
                'title' => $this->input->post('title'),
                'cid' => $this->input->post('category'),
                'date' => $this->input->post('date'),
                'keyword' => $this->input->post('keyword'),
                'description' => $this->input->post('description'),
                'excerpt' => $this->input->post('excerpt'),
                'thumbnail' => $this->input->post('thumbnail'),
                'password' => $this->input->post('password'),
                'content' => $this->input->post('content')
            );
           
            $this->post->add($data);
           
            success('admin/article', '添加文章成功');
        } else {
            $this->load->helper('form');
            $this->load->view('admin/post_add.html');
        }
    }
}
?>

codeigniter 表单验证加载失败

为什么

php$this->load->library('form_validation', 'verify'); 
$this->load->model('category_model', 'cate');

这两个会加载失败?

回复内容:

错误提示:

codeigniter 表单验证加载失败

phpload->model('article_model', 'post');
    }
   
    public function index(){

        $this->load->view('admin/post_list.html');
    }
   
    public function add(){
        $this->load->model('category_model', 'cate');
        $data['category'] = $this->cate->fetch();
       
        $this->load->helper('form');
        $this->load->view('admin/post_add.html', $data);
    }
   
    public function save(){
        $this->load->library('form_validation', 'verify');
        $status = $this->verify->run('article');
       
        if ($status) {
            $data = array(
                'title' => $this->input->post('title'),
                'cid' => $this->input->post('category'),
                'date' => $this->input->post('date'),
                'keyword' => $this->input->post('keyword'),
                'description' => $this->input->post('description'),
                'excerpt' => $this->input->post('excerpt'),
                'thumbnail' => $this->input->post('thumbnail'),
                'password' => $this->input->post('password'),
                'content' => $this->input->post('content')
            );
           
            $this->post->add($data);
           
            success('admin/article', '添加文章成功');
        } else {
            $this->load->helper('form');
            $this->load->view('admin/post_add.html');
        }
    }
}
?>

codeigniter 表单验证加载失败

为什么

php$this->load->library('form_validation', 'verify'); 
$this->load->model('category_model', 'cate');

这两个会加载失败?

/**
 * Class Loader
 *
 * This function lets users load and instantiate classes.
 * It is designed to be called from a user's app controllers.
 *
 * @access  public
 * @param   string  the name of the class
 * @param   mixed   the optional parameters
 * @param   string  an optional object name
 * @return  void
 */

第二个参数是__construct的参数,第三个才是可选的对象名称。

载入类库的时候,是不可以重命名的吧。。。