CodeIgniter Forums

Full Version: Class 'CI_Formgenerator' not found in C:\Users\mycode\system\core\C
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
I have the following code which produces a registration form. It works fine on the page load but on POSTing it tells me that CI_formgenerator cannot be found - even though I've clearly not called the function that. What am I doing wrong?

Code:
    public function index(){
        $this->benchmark->mark('code_start');
        
                $this->load->library('formgenerator',array('register'));

                $this->formgenerator->setupValidation();                        
                
                if ($this->form_validation->run() == FALSE){                                                
                        if (count($_POST)){
                                $this->formgenerator->populateForm($_POST);
                        } else {
                                $sample_data = array();
                                
                                $this->formgenerator->populateForm($sample_data);
                        }
                        
                        $form_out = $this->formgenerator->generateForm();
                        
                        $this->benchmark->mark('code_end');
                        $this->benchmark->elapsed_time('code_start', 'code_end').'<br>';
                        
                        $this->CI->autocontent['form'] = '<ul>'.implode($form_out).'</ul>'; // Autocontent can be an array of variables!
                } else {
                        $this->load->library('formgenerator',array('register'));
                        
                        $this->load->model('register');
                        
                        $this->register->saveUser($_POST);

                        echo 'Your registration has been successful. Please confirm your account in your email';
                }                                                                                
    }

The full error I get is:


A PHP Error was encountered

Severity: Error

Message: Class 'CI_Formgenerator' not found

Filename: core/Common.php

Line Number: 196

Backtrace:

{With no backtrace available}
There is no formgenerator library that comes with CodeIgniter (none that I know of...)
No this is a library I've built myself & have added in.

Thanks
What do you have in your application/core/ directory?
I don't have an application/core folder. According to http://www.codeigniter.com/user_guide/ge...aries.html you put it in your application/libraries folder. I've tried to keep things as "standard" as possible so the location of the file is application\libraries\Formgenerator.php with the following start to my code:

Code:
class Formgenerator {
        
        private $form_output = '';
        
        public function __construct($form_name){
        $ci = get_instance();
(07-09-2015, 10:42 AM)ukuser33 Wrote: [ -> ]I don't have an application/core folder. According to http://www.codeigniter.com/user_guide/ge...aries.html you put it in your application/libraries folder. I've tried to keep things as "standard" as possible so the location of the file is application\libraries\Formgenerator.php with the following start to my code:


Code:
class Formgenerator {
       
       private $form_output = '';
       
       public function __construct($form_name){
       $ci = get_instance();

You do have an empty application/core/ directory by default ... if you don't, then you've manually removed it.

Anyway, as I said in a similar thread, calling $this->load->library() will never trigger the load_class() function (which is the one that has line 196 of system/core/Common.php), unless you've made modifications to the framework.
(07-09-2015, 11:59 AM)Narf Wrote: [ -> ]
(07-09-2015, 10:42 AM)ukuser33 Wrote: [ -> ]I don't have an application/core folder. According to http://www.codeigniter.com/user_guide/ge...aries.html you put it in your application/libraries folder. I've tried to keep things as "standard" as possible so the location of the file is application\libraries\Formgenerator.php with the following start to my code:



Code:
class Formgenerator {
       
       private $form_output = '';
       
       public function __construct($form_name){
       $ci = get_instance();

You do have an empty application/core/ directory by default ... if you don't, then you've manually removed it.

Anyway, as I said in a similar thread, calling $this->load->library() will never trigger the load_class() function (which is the one that has line 196 of system/core/Common.php), unless you've made modifications to the framework.
Ok so how should one call this library() function or is it just a bug/broken?
(07-09-2015, 02:30 PM)ukuser33 Wrote: [ -> ]Ok so how should one call this library() function or is it just a bug/broken?

It looks like you didn't quite understand me ... My point is exactly that the error you're getting has nothing to do with CI_Loader::library() and therefore could not possibly be a bug in the library loading logic.
If you named your library CI_formgenerator then remove the CI_
Pages: 1 2 3