[eluser]Bramme[/eluser]
Okay, I'm having some issues with custom callbacks.
I don't feel like setting them in my controller, so I made a MY_Form_validation library.
It looks like this:
Code:
class MY_Form_validation extends CI_Form_validation {
function unique($str, $field) {
if (empty($str)) {
return FALSE;
}
list($table, $field) = explode('|', $table_field);
$this->CI->db->where($field, $str);
$qry = $this->CI->db->get($table);
if($qry->num_rows() > 0) {
show_error($table.' en '.$field.' fail');
return FALSE;
} else {
show_error($table.' en '.$field.' success');
return TRUE;
}
}
}
In my config item, I set it like this: 'rules' => 'trim|required|unique[users|name]'. I've also added a $lang['unique'] item to the form_validation_lang.php file.
However, it's not working. The class is being loaded correctly, because I get syntax errors, but the moment I use show_error() in my unique function to debug it, it fails, showing only the other validation rules.
Can anybody help me out? Am I doing something wrong or is this is a bug?
edit: god damn. Even putting it in my controller, using the set_message method and the call_back prefix in my config file doesn't seem to work...