开发者

CodeIgniter Validation Callback not being Called

开发者 https://www.devze.com 2022-12-19 16:19 出处:网络
My callback function from validation rules isn’t being called. The other validation rules for that field ARE being called

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 bein开发者_开发技巧g called, but the callback isn't. Thanks!


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.


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."


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消