Can anyone tell me if there is a way to callback with the form_validation library in CodeIgniter to a utility function of a controller? I have a function called check_database
that is a callback function set in form_validation's set_rules
function...the problem is that it's a function in my controller which makes it visible to the router as a method.
I could navigate to index.php/controller/check_database
and it will attempt to render a page rather than coming up with a 404 error. I've already tried making it a utility function by prepending an underscore to the function name, but the set_rules
function doesn't seem to like callback__check_database
.
Is there anyway I can specify the callback function as a utility function...or to hide a non-utility function from being visible to the router in CodeIgniter? This seems like something that should be entirely possible...or should I even be using form_validation
in a Controller
class?
Even the official guide uses a callback function that is in a Controller (http://ellislab.com/codeigniter/user-guide/libraries/form_validation.html#callbacks), so if I went to form/username_check
would the controller not try to render something based on the output of that function?...it wouldn't just 404 I'm guessing.
UPDATE: Currently I have the callback set as callback__check_database
and my function defined as a utility function (_check_database
). This seems to work, however I can't be sure at the moment as I am briefly shown a screen that appears to have some sort of PHP error on it before it reroutes back to my login page. I'm working to find a way to capture that error now.