[eluser]ChrisHJ[/eluser]
Hi,
I'm trying to use a custom validation class with custom validation rules, but for some reason the class never loads.
The set-up is very simple, so I'm just gonna give it all to you here, starting with my function (in controller 'Bruger') when the button is clicked:
Code:
public function glemt_adgangskode()
{
$this->load->library('auth');
$send = $this->input->post('create');
if($send)
{
print_r($this->auth->forgot_password($this->input->post('user_email')));
}
$this->load->view('form');
}
This should bring us to the auth library, in the function forgot_password($user_email):
Code:
public function forgot_password($user_email)
{
$this->ci->load->library('form_validation');
$this->ci->form_validation->set_error_delimiters('<li>', '</li>');
$this->ci->form_validation->set_rules('user_email', 'Email', 'required|tester_valid');
if ($this->ci->form_validation->run() == FALSE)
{
$this->data['val'] = validation_errors();
} else {
$this->data['val'] = "<li>Ny adgangskode bestilt.</li>";
}
return $this->data;
}
I have no problem with the build-in rules ('required' works), but my custom rule 'tester_valid' does not.
My test is very simple:
Code:
class My_Form_validation extends CI_Form_validation {
public function __construct() {
parent::__construct();
$ci = & get_instance();
log_message('debug', 'My_Form_validation loaded');
}
public function tester_valid($var) {
/* doesn't matter, the class never loads! /*
}
The function is empty for now. Like I said, the class is never found by CI, as proved by log:
Code:
DEBUG - 2012-01-28 16:42:13 --> Config Class Initialized
DEBUG - 2012-01-28 16:42:13 --> Hooks Class Initialized
DEBUG - 2012-01-28 16:42:13 --> Utf8 Class Initialized
DEBUG - 2012-01-28 16:42:13 --> UTF-8 Support Enabled
DEBUG - 2012-01-28 16:42:13 --> URI Class Initialized
DEBUG - 2012-01-28 16:42:13 --> Router Class Initialized
DEBUG - 2012-01-28 16:42:13 --> Output Class Initialized
DEBUG - 2012-01-28 16:42:13 --> Security Class Initialized
DEBUG - 2012-01-28 16:42:13 --> Input Class Initialized
DEBUG - 2012-01-28 16:42:13 --> Global POST and COOKIE data sanitized
DEBUG - 2012-01-28 16:42:13 --> Language Class Initialized
DEBUG - 2012-01-28 16:42:13 --> Loader Class Initialized
DEBUG - 2012-01-28 16:42:13 --> Helper loaded: url_helper
DEBUG - 2012-01-28 16:42:13 --> Helper loaded: form_helper
DEBUG - 2012-01-28 16:42:13 --> Controller Class Initialized
DEBUG - 2012-01-28 16:42:13 --> Form Validation Class Initialized
DEBUG - 2012-01-28 16:42:13 --> Language file loaded: language/english/form_validation_lang.php
DEBUG - 2012-01-28 16:42:13 --> File loaded: /application/views/form.php
DEBUG - 2012-01-28 16:42:13 --> Final output sent to browser
DEBUG - 2012-01-28 16:42:13 --> Total execution time: 0.1228
Im using CI 2.1.0, and in the previous version of ci there was no problem..
The really weird part is that other classes with 'MY_' prefix loads just fine, and I can't for the world figure why this particular one doesn't.
Please help me!