![]() |
form_validation with assoc arrays - 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 with assoc arrays (/showthread.php?tid=19223) |
form_validation with assoc arrays - El Forum - 06-01-2009 [eluser]MDomansky[/eluser] Hi, I try to validate array like this Code: array How can I use form_validation class to do it? form_validation with assoc arrays - El Forum - 06-01-2009 [eluser]MDomansky[/eluser] Something like this Code: $this->form_validation->set_rules('specification[][name]', 'lang:project_load_recipient', 'required|min_length[1000]'); or this Code: $this->form_validation->set_rules('specification[(:num)][name]', 'lang:project_load_recipient', 'required|min_length[1000]'); form_validation with assoc arrays - El Forum - 06-23-2009 [eluser]MDomansky[/eluser] Can anybody help me? form_validation with assoc arrays - El Forum - 06-23-2009 [eluser]TheFuzzy0ne[/eluser] Is this not what you're after? Code: $this->form_validation->set_rules($specification[$num]['name'], 'lang:project_load_recipient', 'required|min_length[1000]'); form_validation with assoc arrays - El Forum - 06-23-2009 [eluser]MDomansky[/eluser] In my controller I don't know the count of specifications and their ID's. form_validation with assoc arrays - El Forum - 06-23-2009 [eluser]TheFuzzy0ne[/eluser] Then how can you validate something when you don't know what to validate it against? That doesn't make sense to me. form_validation with assoc arrays - El Forum - 06-24-2009 [eluser]MDomansky[/eluser] I know that my input array has structure specification[(:num)][name], where name - field, (:num) - numeric key. I want to work with validation like I work with route's rules Code: $route['user/(:num)/edit'] = "user/edit/index/$1"; form_validation with assoc arrays - El Forum - 06-24-2009 [eluser]TheFuzzy0ne[/eluser] OK, now I think I understand better. So the array you originally posted isn't something you want to compare to, it's actually the data you want to validate. I don't think validation is the problem, since it should be simple enough to create a custom validation callback that can loop through the array and validate each part. I think the main issue you're going to experience is giving feedback to the user. I don't think you'll be able to do this easily without overriding the validation class, or creating your own. |