Can not extend Form Validator core library |
[eluser]Neerav[/eluser]
Hello Guys, I am using codeigniter version 2.0. I have followed this instruction to extend core form validation library. I try placing my new file named 'MY_Form_validation.php' inside 'application/libraries' and 'application/core' directory respectively. But neither one is working for me. I can not get my valid_url function working. Following is the content of my 'MY_Form_validation.php' file, Code: <?php if (!defined('BASEPATH')) { I am loading form validation library in my controller and default validation methods are working fine. Please advise me what's wrong with this or am I missing any steps. Thanks in advance. Regards, Neerav
[eluser]InsiteFX[/eluser]
The should go into application/libraries If it does not work then something else is wrong check the CodeIgniter User Guide change log to see what has been changed. If the Class you are extending is in system/core then your Class goes into application/core If the Class you are extending is in system/libraries then your Class goes into application/libraries InsiteFX
[eluser]patwork[/eluser]
You don't need to use get_instance() when you're in extended class. This will work: Code: $this->set_message('valid_url', 'The %s field must contain a valid url.'); If you're not sure MY_Form_validation is properly loaded, the best place to check it is it's constructor. Try to add something like: Code: function __construct() Only for debug purposes, of course
[eluser]Neerav[/eluser]
Hi InsiteFX, thanks for reply, I now have it in 'application/libraries' but its not working. I read change log, but I do not find anything relevant there. Hi Patwork, thanks for reply and advise, Its really helpful. I try to check if the library is loading as per your suggestion, but its not loading at all. I read somewhere that I need to place it in 'system/libraries' directory, but I don't think its true, is it? Please advise. Regards, Neerav Dobaria
[eluser]InsiteFX[/eluser]
Code: // This is wrong! InsiteFX
[eluser]Neerav[/eluser]
Hi InsiteFx, They both are identical as far as end result concerned. Thanks, Neerav Dobaria
[eluser]InsiteFX[/eluser]
I just stick to the CodeIgniter standards this way I do not run into other problems. Turn on your logging in application/config/config.php Code: $config['log_threshold'] = 4; InsiteFX
[eluser]Neerav[/eluser]
Hi InsiteFX, agree, I should too stick to Codeigniter standards. I set log threshold to 4 as per your suggestion. It says Form Validation class loaded but it does not tell which one. See below my log, Code: DEBUG - 2011-04-12 11:05:13 --> Config Class Initialized Do you find anything from it? Regards, Neerav Dobaria
[eluser]patwork[/eluser]
Problem must be somewhere else then. Your library must be in: /application/libraries/MY_Form_validation.php With something like this: Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); you should get log like this: Code: DEBUG - 2011-04-12 11:31:44 --> Config Class Initialized
[eluser]Neerav[/eluser]
Hi Patwork, Its really weird. We got everything in common, except the log file. I'll have to debug thoroughly to find out whats the issue. I'll post issue here as soon as I find it. Meanwhile, If you have other suggestion, do let me know. I will be happy to try it as well. Regards, Neerav Dobaria |
Welcome Guest, Not a member yet? Register Sign In |