Welcome Guest, Not a member yet? Register   Sign In
Form validation function callback and field name arrays
#1

[eluser]Unknown[/eluser]
Hello to everyone,

I have some issues with the callback function inside the checkout form validation.
For every row of the form i should to check if the quantity of the item is available taking into account the product id by passing two arrays: id and quantita.
Code:
<?php echo form_hidden("id[]", $ris[$i]['id']); ?>
<?php echo form_input(array("name" => "quantita[]", "value" => $ris[$i]['quantita'], "maxlength" => "3", "size" => "1")); ?>

In my controller I have:

Code:
$id_ricevuto = $this->input->post("id", TRUE);
  
$config = array(array('field' => 'quantita[]', 'label' => 'quantita[]', 'rules' =>"trim|required|numeric|max_length[3]|xss_clean|callback_controlla_quantita"));

By the callback function I can access to the value of the field quantita[] for every row of the form but I need also the respectively value of quantita[].
Are there any way to pass the right value? I mean something like controlla_quantita[quantita[$index]] in the rules?
By using $id_ricevuto I would have all the values passed but I didn't know which is the right.

Any help is very appreciated Smile




Theme © iAndrew 2016 - Forum software by © MyBB