Welcome Guest, Not a member yet? Register   Sign In
Form Validation in custom library?
#1

[eluser]Adam Griffiths[/eluser]
Basically, I'm rewriting my Auth Library and am using the form validation library instead of a bunch of nested ifs.

But the form val library only allows callbacks in the controller...if you've seen the auth library you'll know how it works and how I like it to work, using one line to log a user in, or sign someone up is a great USP (so to speak) so having people add a function to their controller just isn't an option.

Is there any way I can call upon a function inside my library?
#2

[eluser]TheFuzzy0ne[/eluser]
Perhaps you could have your library extend the CI_Controller class, and your controllers extend your library? That should give your library access to the same validation functions as your controller.

I think it would be nice if the callback validation method took a parameter, which could be a reference to the validation function. So we could use callback like this callback_mycallback or callback[$this->myLibrary->myFunction]. That would be backwards compatible, too.




Theme © iAndrew 2016 - Forum software by © MyBB