array fields using form_validation - 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: array fields using form_validation (/showthread.php?tid=53093) |
array fields using form_validation - El Forum - 07-10-2012 [eluser]Yoshiyuki Mikome[/eluser] Hi, everyone. I have some array fields and I wish validate them using form_validation. However, Codeigniter is only to return the following message, I can not know that an error in the position in the array. Code: $error["fieldname[]"] = "message" So, I use My_Form_validation modified as follows. Code: if ( ! isset($this->_error_array[$row['field']])) I want to avoid copying of large functions, such as _excecute. Are there any other good ideas? array fields using form_validation - El Forum - 07-10-2012 [eluser]Aken[/eluser] I would create a callback function or extend the validation class with your own rule(s). array fields using form_validation - El Forum - 07-12-2012 [eluser]Yoshiyuki Mikome[/eluser] Then, I must create a function of each time, or I shall be prepared in advance of all the validation method. Thanks for your reply. array fields using form_validation - El Forum - 07-12-2012 [eluser]tpetrone[/eluser] Can't you validate each $fieldname['value'] ? Looks like the user guide says you can validate the $fieldname[] , why not the $fieldname['value'] ? If this work then you can validate each key=>value in the array. Might work. array fields using form_validation - El Forum - 07-12-2012 [eluser]Yoshiyuki Mikome[/eluser] I have understood it. It required a number of rules same as the array!. Code: $this->form_validation->set_rules('name[0]', '', 'required'); Even though the number of arrays to change, Oh my god! I have attempt to automatically generate both the HTML5 form and validation table from the same definition table. Hmm, I will consider a little more a good way without rewriting the system code. Thunks. |