CodeIgniter Forums
Validation callbacks with model methods - 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: Validation callbacks with model methods (/showthread.php?tid=2904)



Validation callbacks with model methods - El Forum - 08-30-2007

[eluser]feri_soft[/eluser]
How to do a validation callback function when my validation function used for the callback is not in the controller as in the demo but in a model? Whats the syntax if thats possible. I know i can call it in a new controller function and do the rest as described but isnt there a direct way of making it? Thanks!


Validation callbacks with model methods - El Forum - 08-30-2007

[eluser]BravoAlpha[/eluser]
I don't know of a way to do that. What's wrong with making a new function in your controller?


Validation callbacks with model methods - El Forum - 08-30-2007

[eluser]alpar[/eluser]
you can make a MY_Validation class that extends the core and add all your callback functions in it. The validation class looks for it's methods first, so you then just add the method name that you created, without the callback_


Validation callbacks with model methods - El Forum - 08-30-2007

[eluser]feri_soft[/eluser]
Yes those are ways to do it with classes. Well i think it isn't very useful to make one function in a model than create sevceral more functions in each controller that use that model validation function but i will do it this way as there isnt another. Thanks!