CodeIgniter Forums
Callback validation function not getting called - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Callback validation function not getting called (/showthread.php?tid=27484)



Callback validation function not getting called - El Forum - 02-12-2010

[eluser]stef25[/eluser]
I've done this dozens of times before but for some reason the validation function in the code below doesn't get called. $k is the value of the name attribute of a form field. The IF condition gets matched, tested with the die(). The die($str) in the duration_check never shows though;

Can anyone see why?

Code:
function refresh()
    {
        $this->load->library('form_validation');
        
        //loop through all duration fields, make sure they are not zero
        foreach($_POST as $k => $v)
        {
            if( strpos($k, "prod_duration") === 0)
            {                
                //die('here');
                $this->form_validation->set_rules($k, 'Duration', 'callback_duration_check');
            }
            
        }
    }

function duration_check($str)
    {
        die($str);
    }



Callback validation function not getting called - El Forum - 02-12-2010

[eluser]flaky[/eluser]
you need
Code:
$this->form_validation->run();