Validation: Using callbacks from a model |
[eluser]KeyStroke[/eluser]
Hi, I'd like to set the form validation so that callbacks are from a different Model dedicated for validation, instead of the controller the validation resides in. The reason I want that is my application's code is very organized, and I have a bunch of controllers that are going to share the same rules. Is this possible? if not, what do you suggest to solve this issue?
[eluser]The Wizard[/eluser]
i think we had issues with this before, i personally use the callbacks in my controller but there are also people out there, who write a addon to the validation library like my_form_validation and put the validation code in there. ive never been into that but, it kinda works too. i saw it in the recaptchpa files in the wiki, you might check it out.
[eluser]KeyStroke[/eluser]
I couldn't find it. I can't believe the people behind CodeIgniter didn't include such an important feature...
[eluser]The Wizard[/eluser]
i think it was that http://ellislab.com/codeigniter/user-gui...aries.html im not THE expert ![]()
[eluser]KeyStroke[/eluser]
Thanks, but I'm aware of that. But I have no idea how to expand that particular functionality. (I took a look at the form validation file already)
[eluser]jpi[/eluser]
I would like this kind of possibility too. The goal is to be able to use a same callback function for form validation in different controllers. Has someone an idea ?
[eluser]TheFuzzy0ne[/eluser]
Why not store your validation rules in a configuration file? CodeIgniter supports this, and it's the logical place to store them for global access.
[eluser]KeyStroke[/eluser]
[quote author="TheFuzzy0ne" date="1234650375"]Why not store your validation rules in a configuration file? CodeIgniter supports this, and it's the logical place to store them for global access.[/quote]I'd still like to use a callback from a model or a controller, and you can't do that even if you placed the rules in a configuration file, can you?
[eluser]TheFuzzy0ne[/eluser]
I don't see why not... You can access config files from within any object, including models, so I don't see a problem. EDIT: Whoops. Sorry! I was confusing rules with callbacks. I'm so stoopid...
[eluser]KeyStroke[/eluser]
[quote author="TheFuzzy0ne" date="1234651160"]I don't see why not... You can access config files from within any object, including models, so I don't see a problem. EDIT: Whoops. Sorry! I was confusing rules with callbacks. I'm so stoopid...[/quote]I see you've let more blood to get into your caffeine stream. ![]() |
Welcome Guest, Not a member yet? Register Sign In |