![]() |
Fix for undesired result of the valid_ip form validation rule forcing it to be required field - 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: Fix for undesired result of the valid_ip form validation rule forcing it to be required field (/showthread.php?tid=30277) |
Fix for undesired result of the valid_ip form validation rule forcing it to be required field - El Forum - 05-09-2010 [eluser]CroNiX[/eluser] The valid_ip form validation rule runs through the input->valid_ip checker. This in essence makes the field a required field and will fail if empty. Might not be a big deal in some applications, but I have come across an occasion or two where I needed to only check for a valid ip if the field was required by the required rule and ignore it if not required. Original Rule: Code: function valid_ip($ip) The fix is simple, just override it in your MY_Form_validation class. Code: function valid_ip($ip) If in your validation rules you just specify "valid_ip" it will only check the field for a valid ip if its not empty, making it not required like I think it should be. ![]() |