[eluser]coffeeandcode[/eluser]
[quote author="Jondolar" date="1282620184"]Can you create a callback function when validating the quantities variable and then validate the individual array items yourself? I think I already had this issue and may have already solved this. I'll check when I get home.[/quote]
I can, but I can only get it to match the variable if I put the product ids into the form validation config:
Code:
$config["orders/bulk"] = array(
array(
"field" => "quantity[155530],
"label" => "quantity for product #155530",
"rules" => ""
),
array(
"field" => "quantity[252605],
"label" => "quantity for product #252605",
"rules" => ""
),
...
)
And then it treats them each as separate variables and validates them separately. This doesn't work because I want it to validate when the user has entered at least one product, of any id. ie, it should validate if one of the product quantities is greater than 0. I need it to be treated as a single variable.
I also tried putting the ids and quantities into 2 different branches of a 2 dimensional array:
Code:
<input class="quantity" type="text" size="1" name="quantities[quantity][]" value="<?php echo set_value("quantities[quantity][]") ?>" />
<input type="hidden" name="quantities[id][]" value="<?php echo $item["id"] ?>" />
and in this case it triggers the form validation properly, but it is still validating each array element separately. And it is a lot messier than what I was doing without the form validation library.
Am I missing something? Is this not the way html input arrays are supposed to be used? Is there a cleaner way of doing what I'm trying to accomplish?