Welcome Guest, Not a member yet? Register   Sign In
calling a library function in callback
#1

[eluser]newtonianb[/eluser]
How can I call a library function in a form validation callback?
Like
$this->form_validation->set_rules('my_var', '"Variable Input"', 'required|alpha|callback__$this->myLib->checkMyVar');
#2

[eluser]cahva[/eluser]
Not possible as CI checks for the method in $this->CI object. But you could just create the callback in that controller where you use your library:
Code:
function check_my_var()
{
    return $this->my_lib->check_my_var();
}
#3

[eluser]newtonianb[/eluser]
Thanks cahva, that's what i'm doing now but I was trying to clean things up since I need to call this function in most of my controllers I wanted to remove that extra local function proxy
#4

[eluser]newtonianb[/eluser]
FYI
I found a great way to do this. I extended form_validation and this extended form validation the calls my library functions.




Theme © iAndrew 2016 - Forum software by © MyBB