Welcome Guest, Not a member yet? Register   Sign In
Validation callback issue


I have something like this in my controller:

$rules['parentid'] = "callback_parental_check";

function parental_check($parent)


It's working fine but I need to pass another parameter for parental_check function to compare it with $parent variable. How can this be done?


If you look at the validation library and other callbacks, you notice how some use smth like callback[variable]. When I had a look at the library, I noticed the functions off those callbacks had $variable set as the second parameter... Not sure if it's that easy, but it won't hurt to try, won't it?

I don't get it. How should my code look like?


By the way, I'm not even able to set a var at the beginning of the Controller, like

var blablabla;

The callback function can't see it Sad


It's really easy...

Just do:

$rules['parentid'] = 'callback_parental_check[blah]';

function parental_check($parent, $variable)
  // $variable == 'blah' now, because it's been passed in!
  // Insert code for doing the check or whatever

Hope that helps!


That worked, thank you so much.

Theme © iAndrew 2016 - Forum software by © MyBB