Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] Form validation callback method in MODEL instead of controller -- Read me if you want the answer.
#7

[eluser]Mirge[/eluser]
After MUCH headache... I decided to revisit the previous URL and re-try the code.

It still didn't work.

I started tracing through it... and the example shows you're supposed to invoke a callback method in the MODEL via:


callback_methodname_model[modelname]


So, I continued tracing through the code... echo statements & what not. Then I discovered that $rule was NOT saving the [modelname] portion.

Seconds later, I found the regular expression:

Code:
if (preg_match("/(callback_\w+)/", implode(' ', $rules), $match))

needless to say, I let out a sigh of relief. \w won't match brackets.

I changed the regex to:

Code:
if(preg_match("/(callback_[\w\[\]]+)/", implode(' ', $rules), $match))

And it's now calling the correct validation method within the model specified. All is right with the world again.

Figured I'd share... since the only forum results I could find via searching were not helpful. Hopefully this saves somebody else the hassle/headache.


Messages In This Thread
[SOLVED] Form validation callback method in MODEL instead of controller -- Read me if you want the answer. - by El Forum - 08-04-2011, 11:47 PM



Theme © iAndrew 2016 - Forum software by © MyBB