• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Form validation callbacks not working

#1
Hello,

After upgrade from 2.2.6 to 3.1.9. I noticed my callback function for form validation not working.

PHP Code:
function update_password()
    {
        
        if(
$this->session->userdata('recovery')!='yes')
        
$this->form_validation->set_rules('current_password''Current Password''callback_currentpass_check');
        
        
$this->form_validation->set_rules('new_password''New Password''required|matches[re_password]');
        
$this->form_validation->set_rules('re_password''Password Confirmation''required');
            
        if (
$this->form_validation->run() == FALSE)
        {
            
$this->changepass();    
        }
        else
        {
            
                
$password $this->input->post('new_password');
                
$this->auth_model->update_password($password);
                
$this->session->set_userdata('recovery',"no");
                
$this->session->set_flashdata('msg''<div class="alert alert-success">Password changed successfully</div>');                
            
            
redirect(site_url('admin/auth/changepass'));        
        }
    
    } 



PHP Code:
public function currentpass_check($str)
    {
        
$user_name 'test_user';
        
$res $this->auth_model->check_login($user_name,$str);
        
        if (
$res == 0)
        {
            
$this->form_validation->set_message('currentpass_check''Current password Didn\'t match');
            return 
FALSE;
        }
        else
        {
            return 
TRUE;
            
        }
    } 

I am getting this error.
[Image: 50575236-2500a200-0e03-11e9-97ae-d19325f4aa60.png]
My callback function ( currentpass_check) returns TRUE.
Reply

#2
Instead of 
PHP Code:
$this->form_validation->set_message('currentpass_check''Current password Didn\'t match'); 
try this:

PHP Code:
$this->form_validation->set_message('current_password''Current password Didn\'t match'); 

untested...
Reply

#3
@codehoster,

...or simply try using the double quotes.


PHP Code:
$this->form_validation->set_message('current_password'"Current password Didn't match"); 
Reply

#4
(01-02-2019, 11:34 AM)Codinglander Wrote: Instead of 
PHP Code:
$this->form_validation->set_message('currentpass_check''Current password Didn\'t match'); 
try this:

PHP Code:
$this->form_validation->set_message('current_password''Current password Didn\'t match'); 

untested...

Same error!

https://www.codeigniter.com/userguide3/l...ation.html

In documentation your recommendation is not valid.


Attached Files Thumbnail(s)
   
Reply

#5
Try changing it to this:

PHP Code:
$this->form_validation->set_message('current_password''Current password do not match'); 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#6
Are you absolutely sure that it returns TRUE? It dosen't need to access a message in case it's TRUE, only on FALSE.
Are these function placed in the same .php file or are you extending it?
Reply

#7
Yes I am absolutely sure!
Reply

#8
@Codehoster,

Did you try the double quotes? Just wondering?
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
2 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.