CodeIgniter Forums
Advanced Form Validation question - 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: Advanced Form Validation question (/showthread.php?tid=51997)



Advanced Form Validation question - El Forum - 05-25-2012

[eluser]The Revel[/eluser]
Is there a way to set up form validation based on whats filled out in the form, for instance if a certain field has a certain value, it checks another field for a certain value.

What I am trying to set up is that if the type of transaction is set to Refund that the manager has to put in their code in another field for it to pass. All other types of transaction will ignore the second field, its only required on refunds.


Advanced Form Validation question - El Forum - 05-25-2012

[eluser]Aken[/eluser]
Options:

- Create a callback rule.
- Extend the library with a custom rule (good if using it in multiple places).
- Check for the existence of the Refund item, and set the required rule if it exists.


Advanced Form Validation question - El Forum - 05-25-2012

[eluser]The Revel[/eluser]
Thank you Aken, I read about the Call back functions in the form validation documentation, will see fi I can come up with something. Unfortunately I am still coding my first codeigniter app and am still very new to the whole thing so I know I am gonna be back asking questions LOL.