[eluser]Hartimer[/eluser]
Hi
So, i'm using form validation for, guess what, form validation.
The thing is, this specific form is part of a custom library, therefore i think it would be suitable to place it under a method inside the lib itself.
Code:
class My_Lib{
var $CI;
function form(){
$this->CI =& get_instance();
$this->CI->load->library('form_validation');
$this->CI->load->helper('form');
$this->CI->form_validation->set_rules('username', 'Username', 'trim|required|xss_clean|callback__username_exists');
(...)
}
function _username_exists($str){
if(USERNAME_EXISTS){
$this->CI->form_validation->set_message('_username_exists', '%s unavailable.');
return FALSE;
}
return TRUE;
}
}
Problem is, the function "_username_exists" is not called. As far as i can tell, the form validation library tries to run the function as it was part of the controller, not the library. Substituting things accordingly, if the form + callback method are defined within the controller, no problems occur.
Is there anyway the callback functionality can reference a library method?