views:

258

answers:

3

Hi all, My callback function from validation rules isn’t being called. The other validation rules for that field ARE being called

$rules[‘login_name’] = “required|max_length[12]|alpha_dash|callback__check_login_name”;
function _check_login_name($login_name) {
    echo "here"; // DOESNT WORK
 }

So in the above line, required, max_length, alpha_dash are being called, but the callback isn't. Thanks!

A: 

For testing, try this instead of the echo:

function _check_login_name($login_name) {
    $this->form_validation->set_message('_check_login_name', 'The callback was called.');
    return FALSE;
}

Per the callbacks entry in the CI manual: "If your callback returns anything other than a boolean TRUE/FALSE it is assumed that the data is your newly processed form data."

Trae
The value of the return should not have anything to do with whether the echo is working, unless he is somehow calling that inside of the view...
Christopher W. Allen-Poole
A: 

It could be that the method is somehow not readable out of scope. Does it work when you simply call _check_login_name manually (from outside of the class)? If that is not the issue, then have you tried placing echo's in the system folder's Form_validation.php? Place a series in after line 581. After that, more code will be needed in order to give more help.

Christopher W. Allen-Poole
A: 

I have a feeling that you're using the old validation class. Try the new Form Validation Class. I think there was a bug with that in the old one.

Thorpe Obazee
that might be it; will check it out
Michael