form_validation of arrays: what does CI when first array index != 0 - 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: form_validation of arrays: what does CI when first array index != 0 (/showthread.php?tid=38766) |
form_validation of arrays: what does CI when first array index != 0 - El Forum - 02-18-2011 [eluser]Unknown[/eluser] Hello, i've experienced an issue when validating a post array. For example: This one works perfect. Code: <!-- validation rule --> But: Code: <!-- validation rule --> Has anyone had the same problem or already got a workaround for it? Greetings form_validation of arrays: what does CI when first array index != 0 - El Forum - 02-18-2011 [eluser]Unknown[/eluser] After some research in the form_validation.php library i came to the conclusion, that this could really be a bug. For me it worked after replacing the recursive call at the top of _execute by a new one: Code: function _execute($row, $rules, $postdata = NULL, $cycles = 0) $cycles is later used as the array index of the posted array. but it always starts to count at 0, so if we have unordered array indices (which is in fact possible by giving the form element a concrete index in the name field), it would not work. BUT: i did not test this for other solutions than mine, for example multidimensional arrays form_validation of arrays: what does CI when first array index != 0 - El Forum - 08-15-2012 [eluser]NeoArc[/eluser] Hmm, is the $cycles parameter really needed? (Sorry for the bump) Perhaps it should be renamed instead. |