help me about form validation callback function |
[eluser]ali oygur[/eluser]
hi, Sorry, im little speak english my from turkey. i have a problem about form_validation callback. form validation callback function not work in my class. Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); but this code working in controller file. Please help me ![]()
[eluser]LuckyFella73[/eluser]
Hi ali oygur Looks like you put all/most of the code usually found in a controller/ model into a library and load that stuff into your controller. I recommend you to organize your code better to make everything much easier! Setting up a new library makes sense if you build a class and functions you don't have yet. Your library is just a mix of libraries allready existing, what is making everything more complicated then necessary. Would be better if you place the rules (including the callback function) inside your controller and set up one model with the database functions.
[eluser]ali oygur[/eluser]
[quote author="LuckyFella73" date="1274127050"]Hi ali oygur Looks like you put all/most of the code usually found in a controller/ model into a library and load that stuff into your controller. I recommend you to organize your code better to make everything much easier! Setting up a new library makes sense if you build a class and functions you don't have yet. Your library is just a mix of libraries allready existing, what is making everything more complicated then necessary. Would be better if you place the rules (including the callback function) inside your controller and set up one model with the database functions.[/quote] @luckyfella73 very thanx for your help. i will do your say. but One way to do it yet? So, not work in other class (my class, my librariy) callback function ? note : im sorry for my english
[eluser]WanWizard[/eluser]
Form validation looks for the callback method only in the loaded controller, so in your case $this->CI->_username_exists() must exist for the callback to function. You have a few options: If this validation code is specific to this controller, put the callback code back into your controller. If you want to reuse the validation code in a few other controllers, put the code in a library or model, then create a callback method in your controller that calls the model/library method. If you want to use the validation code everywhere, extend the form validation library and put the method in your extension, so you can use it like any other rule (without the callback prefix).
[eluser]LuckyFella73[/eluser]
What exactly does not work? Do you get any error messages? If yes please post along with your controller code. I don't know if I'll be able to help you but I can at least have a look at it and try.
[eluser]WanWizard[/eluser]
@luckyfella73, You don't get an error message. If $this->CI->your_callmethod_method() does not exist, the form validation library simply skips your rule.
|
Welcome Guest, Not a member yet? Register Sign In |