CodeIgniter Forums
Callback Validation with using two arrays for field names - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: Callback Validation with using two arrays for field names (/showthread.php?tid=49488)



Callback Validation with using two arrays for field names - El Forum - 02-21-2012

[eluser]it.peds[/eluser]
In the view, I have several pairs of input fields like below
Code:
<input type="text" name="address[]" value="" />
<input type="text" name="type[]" value="" />

In the controller, I want to set up a callback validation like
Code:
$this->form_validation->set_rules('type[]', 'Address Type', 'callback_requireIfAssoicatedAddressIsFilled[address[]]');

Please advise on how I can code the callback validation, so type[0] is checked with only address[0] not the whole array when looping through the form_validation.excute()


Callback Validation with using two arrays for field names - El Forum - 02-21-2012

[eluser]pbflash[/eluser]
Maybe something like this:
Code:
foreach ($type as $k => $v)
}
    $add_type = $v;
    $address = $address[$k];
    
}



Callback Validation with using two arrays for field names - El Forum - 02-21-2012

[eluser]InsiteFX[/eluser]
I wish you people would quit using this forum topic for asking question! This forum topic is users that contribute libraries and other code for users.

The only question that should be asked in here are one that pertain to the libraries or code posted in here not genral questions.