0

这很奇怪,当 set_rules 被告知要查找current_password它时它还不起作用,而当它被告知要查找current-password它时。

<input type="password" name="current_password" id="current_password" value=""/>

请注意,name 和 id 都有一个下划线。

$this->form_validation->set_rules('current_password', 'Password', 'required|callback_check_password['.$user_id.']');
//This gives me
Unable to access an error message corresponding to your field name.

上述规则不起作用,但如果我也更改它,set_rules('current-password'它开始显示错误消息。

打印错误消息<?php echo validation_errors(); ?>

做一个帖子展示的转储array(1) { ["current_password"]=> string(4) "test" }

4

1 回答 1

0

我没有在回调函数中设置错误消息

function check_password($password, $user_id){
    $check = $this->Usermodel->check_password($password, $user_id);
    if($check){
        return TRUE;
    } else {
        $this->form_validation->set_message('check_password', 'Incorrect password');
        return FALSE;
    }
}
于 2012-09-26T01:04:38.807 回答