Using form validation to validate the $post array - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Using form validation to validate the $post array (/showthread.php?tid=491) |
Using form validation to validate the $post array - cbiz316 - 12-10-2014 Hi all quick question i have a form which has alot of fields which are labeled as item1 item1a item2 item2b item3 item3b ect all the way up to 52 they will all need to be validated with the same options can i use the $post array in the validation $data = $this->input->post(NULL, TRUE); $this->form_validation->set_rules($data, 'data', 'required'); if ($this->form_validation->run() == FALSE) { echo "fail"; } else { echo "win"; } so i can validate them all in one swoop rather than doing a separate line for each ? many thanks cbiz RE: Using form validation to validate the $post array - Rufnex - 12-11-2014 You can set your rules by a simple loop like that (untested but i should work). PHP Code: for ($i=1; $i<=52; $i++) You need a logic inside for your labeling .. dont see a exact logic there item1, item1a .. then item2, item2b .. etc. or all item {number|number.b}? |