Using another rule if callback returns false - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Using another rule if callback returns false (/showthread.php?tid=49271) |
Using another rule if callback returns false - El Forum - 02-13-2012 [eluser]Unknown[/eluser] I'm using the following rule for my input: Code: callback_validate_host I need to make the following condition: if Code: callback_validate_host So if validation of both: callback_validate_host and valid_ip on one input if FALSE then is should throw an error message. How can I do that? Using another rule if callback returns false - El Forum - 02-13-2012 [eluser]CroNiX[/eluser] Haven't tried this, but you might try: 1) In your callback, if validate_host() is TRUE, return TRUE and you're done, else 2) Run it through the valid_ip() rule, like $valid_ip = $this->CI->form_validation->valid_ip($str); 3) If $valid_ip === TRUE, return TRUE, if FALSE, set an error message for "validate_host" (as opposed to valid_ip since validate_host is the name of your callback rule) and return FALSE. I don't think it will automatically find the error message for the valid_ip rule since it wasn't set up as an original rule in form_validation:et_rules(); Again, I haven't tried this. |