Array validation - 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: Array validation (/showthread.php?tid=9425) |
Array validation - El Forum - 06-24-2008 [eluser]EEssam[/eluser] Hello, I'm using CI validator and I need to validate an array. It looks like this into my view file: <input type="text" value="order[1]" name="one"> <input type="text" value="order[2]" name="one"> <input type="text" value="order[3]" name="one"> $rules['order'] = "numeric"; is not working. I need to show the error if any field doesn't contain a number. Please help. Array validation - El Forum - 06-25-2008 [eluser]Matthieu Fauveau[/eluser] Hi, Maybe it's a typo, but you should use is_numeric not numeric 'cause it's not a function. Array validation - El Forum - 06-25-2008 [eluser]Yash[/eluser] I guess array validation is not supported by CI..I'm not sure Array validation - El Forum - 06-25-2008 [eluser]Armchair Samurai[/eluser] [quote author="Matthieu Fauveau" date="1214394188"] Maybe it's a typo, but you should use is_numeric not numeric 'cause it's not a function.[/quote] The OP is more-than-likely using the CI Validation rule numeric, not the PHP function. Array validation - El Forum - 06-25-2008 [eluser]Matthieu Fauveau[/eluser] [quote author="Armchair Samurai" date="1214397451"][quote author="Matthieu Fauveau" date="1214394188"] Maybe it's a typo, but you should use is_numeric not numeric 'cause it's not a function.[/quote] The OP is more-than-likely using the CI Validation rule numeric, not the PHP function.[/quote] I thought he tried to use the ability to call one argument PHP functions from validation. My bad Array validation - El Forum - 06-25-2008 [eluser]EEssam[/eluser] Hi guys, So the only way is to create a custom callback function I guess. Array validation - El Forum - 06-25-2008 [eluser]parrots[/eluser] Numeric should work, but why are you defining $rules['order'] when the input name is 'one'? The key in the rule array and the input's name should match up. So it'd be $rules['one'] (although you might not want 3 text boxes named the same thing?). |