Complex Form Validation? With or Without Rules? - 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: Complex Form Validation? With or Without Rules? (/showthread.php?tid=53907) |
Complex Form Validation? With or Without Rules? - El Forum - 08-13-2012 [eluser]Unknown[/eluser] What is the preferred way to deal with complex form validation? I have data that is selected from dropdowns that has to be checked to verify that the values submitted exist in the database or not. Do most people just create custom callback functions to check that these values exist, or do they keep form validation for simple rules and then if those simple rules pass then they check the more complicated stuff? For example: Code: $this->form_validation->set_rules('ad_type', 'Ad Type', 'required|is_natural'); OR: Code: function check_ad_types(type_id, sub_type_id) { Certainly the second way is cleaner, does anyone have a preference? Complex Form Validation? With or Without Rules? - El Forum - 08-14-2012 [eluser]iamzozo[/eluser] I would also go on with the second one It's cleaner, and i think thats why codeigniter has callbacks in validation, to extend with your own. |