Welcome Guest, Not a member yet? Register   Sign In
callback feature on form validation library
#11

[eluser]bretticus[/eluser]
Possibly the original post was edited but did anyone notice that the method that was called back has a big fat exit() in it? Of course it didn't work! By calling it you stop the rest of the script from running. Certainly, not a bug. Callbacks must return a boolean. Of course, this post was overlooked long ago no doubt and my contribution is moot. Smile
#12

[eluser]coolgeek[/eluser]
The callback does not have to return a boolean. As noted in the documentation, if you return anything other than a boolean, the return value replaces the field value.

However, you have to return something, otherwise you incur problems. I discovered this when I failed to return TRUE from my callbacks. I consider this a documentation bug, along with the failure to note that callback functions are expected to reside in the controller.
#13

[eluser]bretticus[/eluser]
[quote author="coolgeek" date="1251999364"]The callback does not have to return a boolean. As noted in the documentation, if you return anything other than a boolean, the return value replaces the field value.

However, you have to return something, otherwise you incur problems. I discovered this when I failed to return TRUE from my callbacks. I consider this a documentation bug, along with the failure to note that callback functions are expected to reside in the controller.[/quote]

Yes, I guess the whole notion of using the form validation to "process form data" seems strange to me (okay, trim() makes sense.) However, you are right.

Even though it doesn't spell it out, the only example that is given shows a callback method within the same controller. Since there would have to be someway to specify the callback function being elsewhere and no instructions are given, I'm sure the author just assumed it was obvious. No doubt this has been a source of confusion to some.

Good luck getting them to be more specific in the documentation.
#14

[eluser]coolgeek[/eluser]
As it turns out, what was tripping me up is that when using callback functions in MY_Form_validation.php, you DO NOT prefix the callback function name with "callback_" in the set_rules function.

(thanks to this and its followup:

http://www.scottnelle.com/41/extending-c...n-library/

It may not be immediately obvious from my post that that was my problem (since I referenced function_name instead of callback_function_name). But then this isn't my first post on the issue - an issue that I've wasted a good chunk of the last two months trying to figure out.

Would somebody please put this in TFM




Theme © iAndrew 2016 - Forum software by © MyBB