Welcome Guest, Not a member yet? Register   Sign In
Array validation
#1

[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.
#2

[eluser]Matthieu Fauveau[/eluser]
Hi,

Maybe it's a typo, but you should use is_numeric not numeric 'cause it's not a function.
#3

[eluser]Yash[/eluser]
I guess array validation is not supported by CI..I'm not sure
#4

[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.
#5

[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 Wink
#6

[eluser]EEssam[/eluser]
Hi guys,

So the only way is to create a custom callback function I guess.
#7

[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?).




Theme © iAndrew 2016 - Forum software by © MyBB