[eluser]Philo01[/eluser]
[quote author="BrianDHall" date="1253600889"]This might be too easy, but in your password_match function remove the if check - just set the form validation message and return false regardless. Still getting the error?
If not, you can always leave the set_message outside the loop anyway - you can set the message even if it is going to return true as error messages are only shown if the validation fails.
This is all inside a controller, right?[/quote]
Thanks for your reply, I tried what you said but it didn't work
Code:
function validate_password_change(){
$this->form_validation->set_rules('current_password', 'Current Password', 'trim|required|callback_password_match');
$this->form_validation->set_rules('password', 'Password', 'trim|required|min_length[4]');
$this->form_validation->set_rules('password_match', 'Confirm Password', 'trim|required|matches[password]');
$this->form_validation->set_message('current_password', 'Your old password is incorrect');
if($this->form_validation->run() == FALSE){
$this->change_password();
}else{
echo 'Updated';
}
}
function password_match($str)
{
if (md5($str) != $this->userlib->current_password()){
return FALSE;
}else{
return TRUE;
}
}
I still get
Quote:Unable to access an error message corresponding to your field name.
Anyone else got a solution? Would really appreciate it!
Thanks!