[eluser]gh0st[/eluser]
I'm wanting to put my validation rules in a model, rather than in my controller; that way we keep to the rule of "skinny controllers, fat models" -- I've also seen in other frameworks where they put the rules for validation in the model.
However, I am unable to get it to work.
Code:
class News_m extends Model
{
public function News_m()
{
parent::__construct();
/*
$this->load->library('form_validation');
$this->form_validation->set_rules('username', 'Username', 'required');
$this->form_validation->set_rules('password', 'Password', 'required');
$this->form_validation->set_rules('passconf', 'Password Confirmation', 'required');
$this->form_validation->set_rules('email', 'Email', 'required');
*/
$this->load->library('form_validation');
$this->form_validation->set_rules('password', 'Password', 'required');
}
}
The above gives me an error:
Quote:Call to a member function set_rules() on a non-object
I've tried putting $this->CI->form_validation and even parent::form_validation->set_rules
Neither of these two work.
Is there another way to fix this issue?
Thanks.