Validation callback in a CI package |
[eluser]Johnny Freeman[/eluser]
I cannot, for the life of me, get form validation callbacks to work in a CI package (application/third_party). Here is a thread I created on MojoMotor's forum (with no luck) explaining the issue and with code examples. Are you supposed to be able to use callbacks in a package?
[eluser]Johnny Freeman[/eluser]
Come on, someone has got to know the answer to this.
[eluser]InsiteFX[/eluser]
You need to specify what version of CI you are using! But as far as I know about From_Validations the callback has to be in the same class. InsiteFX
[eluser]Johnny Freeman[/eluser]
I'm using CI 2 core (not reactor). It comes with the MojoMotor CMS. I'm making an addon for MM which is essentially a CI package. Are you suggesting that some version of CI does support the use of callback validations from within packages? FYI, my callback is in the same class.
[eluser]Johnny Freeman[/eluser]
Code: class Form This example should work... but it does not. I've also tried extending the form_validation library from within a MM addon (or CI package) which doesn't seem possible either.
[eluser]kenny.katzgrau[/eluser]
Is the code snippet above a controller being called directly? In the core library, callbacks are called on the CodeIgniter Superobject (ie, the controller).
[eluser]kenny.katzgrau[/eluser]
Actually, I realized that you're doing this from inside a package. Because you can't use controllers inside packages (they are essentially a bundle of libraries), you won't be able to use callbacks. Just to say that a little more clearly, callbacks are only called on controllers, and controllers won't be loaded from within packages.
[eluser]Johnny Freeman[/eluser]
Thank you VERY much! That's exactly what I was looking for. Now my question is, would it be possible for me to somehow "inject" the callback into the CI Superobject? Forgive me, that's probably a stupid question. OR Is it possible to extend core libraries from within a package?
[eluser]Johnny Freeman[/eluser]
It's okay if it's not possible because I can do what I want using raw php but I'd rather use some CI goodness if I can.
[eluser]kenny.katzgrau[/eluser]
You could definitely add the injection functionality by extending the controller and adding some methods to register a callback internally, and listen for it using __call(). But it might be more complicated than it's worth for what you're doing. If raw PHP is an option, that might be your best bet ![]() |
Welcome Guest, Not a member yet? Register Sign In |