php - Form Validation Won't Work if Load Two Models - CodeIgniter -


i have 1 controller , try load 2 models (usermodel , contentmodel) , need load form validation library. use usermodel user such login , register, , need contentmodel web content. @ first able login , register , had no problem form validation library, when add line $this->load->model('contentmodel'); load contentmodel, error:

call member function load() on non-object in /var/www/html/webappadmin/system/libraries/form_validation.php on line 455

if remove line $this->load->model('contentmodel'); goes normal again.

controller (controll.php):

defined('basepath') or exit('no direct script access allowed');  class controll extends ci_controller {  /**  * index page controller.  *  * maps following url  *      http://example.com/index.php/welcome  *  - or -  *      http://example.com/index.php/welcome/index  *  - or -  * since controller set default controller in  * config/routes.php, it's displayed @ http://example.com/  *  * other public methods not prefixed underscore  * map /index.php/welcome/<method_name>  * @see http://codeigniter.com/user_guide/general/urls.html  */  public $lang; public $logo; public function __construct () {     parent::__construct();     $this->load->helper('url');     $this->load->helper('form');     $this->load->model('contentmodel');     $this->load->model('usermodel');     $this->load->library('session');     $this->load->library('form_validation');     /*get user sessions data*/     $this->sesi = $this->session->all_userdata();     $config = $this->contentmodel->load_config();     $this->lang = $config['lang'];     $this->logo = $config['image_logo_path'];     $data['lang'] = $this->lang;     $this->load->view('/header/header'); }  public function panel(){     $this->form_validation->set_rules('email', 'email', 'required');     $this->form_validation->set_rules('cred', 'password', 'required');      if($this->form_validation->run() === false){         echo '<center style="position: relative;z-index:10000;font-family: \'roboto\', sans-serif;color:white;top: 62%;">'.validation_errors().'</center>';         $this->load->view('login');     }else{         $user = $this->usermodel->login();         if($user == 0){             echo '<center class="logerror" style="position: relative;z-index:10000;font-family: \'roboto\', sans-serif;color:white;top: 62%;">username or password incorect. please try again</center>';             $this->load->view('login');         }else{             $data['data'] = 2;             $data['user'] = $user;              $this->load->view('/header/navbar',$data);             $this->load->view('panel');             $this->load->view('/footer/footer');         }     } } 

and also, if remove/comment these lines:

$this->form_validation->set_rules('email', 'email', 'required'); $this->form_validation->set_rules('cred', 'password', 'required'); /* ... */ if($this->form_validation->run() === false){ /* ... */ }else{ /* ... */ } 

everything goes normal again well.

please me. in advance.

the problem $lang variable. can see, form_validation library using ($this->ci->lang->load('form_validation');) . change else, , set private. rule, variable inside controller should set private, or else have such issues.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -