这很糟糕,当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" }
答案 0 :(得分: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;
}
}