![]() |
The problem when extend the form_validation system library - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: The problem when extend the form_validation system library (/showthread.php?tid=23577) |
The problem when extend the form_validation system library - El Forum - 10-15-2009 [eluser]luffy[/eluser] I create one form_validation file in my application/library directory: filename: Form_validation.php Class name: MY_Form_validation The class code like this: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class MY_Form_validation extends CI_Form_validation { .... } The error exist when run: Fatal error: Class 'CI_Form_validation' not found in E:\www\application\libraries\Form_validation.php on line 3 The problem when extend the form_validation system library - El Forum - 10-15-2009 [eluser]khagendra[/eluser] filename: Form_validation.php Class name: MY_Form_validation the filename should be the name of class. do like this, it will work filename: MY_Form_validation.php Class name: MY_Form_validation The problem when extend the form_validation system library - El Forum - 10-15-2009 [eluser]imn.codeartist[/eluser] Ok here what you have done wrong Make file name in your application/library directory: MY_Form_validation.php then in your class Code: class MY_Form_validation extends CI_Form_validation in your controller Code: class Test extends Controller I bet this will work The problem when extend the form_validation system library - El Forum - 10-15-2009 [eluser]wiredesignz[/eluser] Do NOT load the MY_Form_validation extension library. Load Form_validation as you would normally. The MY_Form_validation extension class will be loaded by CodeIgniter automatically. Code: $this->load->library('form_validation'); @dixcoder, I suggest you go back and read the user guide again before giving people help. The problem when extend the form_validation system library - El Forum - 06-07-2011 [eluser]Sarwar CSE[/eluser] Same Problem path application/library/GSValidation.php class : Code: class GSValidation extends CI_Form_validation{ when i load the library by this $this->load->library('GSValidation') then the error shows Code: Fatal error: Class 'CI_Form_validation' not found in \application\libraries\GSValidation.php on line 2 Please Advice me The problem when extend the form_validation system library - El Forum - 03-25-2012 [eluser]moriokasan[/eluser] Just in case someone still needs this: The error is generated by a bad naming in the file names and class names. This is in direct correlation with the prefix definition in 'config.php' file : Code: $config['subclass_prefix'] = 'MY_'; Considering that the prefix is 'MY_' then in application/libraries create a file named 'MY_Form_Validation.php' with content: Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); Then in your controller use 'form_validation' as you would normally use: Code: $this->load->library('form_validation'); Good luck! |