![]() |
Split 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: Split Form Validation (/showthread.php?tid=27502) |
Split Form Validation - El Forum - 02-12-2010 [eluser]CodeIgniterNewbie[/eluser] I have some forms wherein the validation requires a callback to the DB, a web service, etc. Individually, these callbacks don't take up that much time. However, collectively, the do. So, I want to do the basic validations on all the form fields first -- and if those pass, only then do I do the other type of validations. For example, say I have a field "email_address", I first want to do the following: Code: 'field' => 'email_address', And then do the rest of the fields in a similar way. If they all pass, then I do the validations that take a longer time. How is this done? Split Form Validation - El Forum - 02-12-2010 [eluser]kirkaracha[/eluser] I believe the form fields and rules get evaluated in the order they appear, so as the last rule for the last form field maybe you could do a callback that does the database query, web service, etc. based on the form inputs. (The callback should be on a required field so it always gets evaluated.) Since the callback would come after all of the validation rules, the data should be valid at that point. Split Form Validation - El Forum - 02-12-2010 [eluser]danmontgomery[/eluser] You can just call one callback in form_validation, and nest the rest within that one. Code: function callback_function1($str) { Split Form Validation - El Forum - 02-12-2010 [eluser]CodeIgniterNewbie[/eluser] [quote author="kirkaracha" date="1266033113"]I believe the form fields and rules get evaluated in the order they appear, so as the last rule for the last form field maybe you could do a callback that does the database query, web service, etc. based on the form inputs. (The callback should be on a required field so it always gets evaluated.) Since the callback would come after all of the validation rules, the data should be valid at that point.[/quote] Assume that there are 10 fields and each field has a callback that takes 10 seconds each. Assume that the first 9 fields all pass validation (using the 90 seconds for the callbacks). When the 10th field is validated, it turns out that it is a required field and the user forgot to populate it. 90+ seconds have gone by before it figured that out. Not good. So, at a "field" level, this approach might work. However, at a "form" level, it doesn't. Split Form Validation - El Forum - 02-12-2010 [eluser]CodeIgniterNewbie[/eluser] [quote author="noctrum" date="1266033273"]You can just call one callback in form_validation, and nest the rest within that one. Code: function callback_function1($str) { This might work. I'll look into it. |