Welcome Guest, Not a member yet? Register   Sign In
Class 'CI_Formgenerator' not found in C:\Users\mycode\system\core\C
#1

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}
Reply
#2

There is no formgenerator library that comes with CodeIgniter (none that I know of...)
Reply
#3

No this is a library I've built myself & have added in.

Thanks
Reply
#4

What do you have in your application/core/ directory?
Reply
#5

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();
Reply
#6

(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.
Reply
#7

(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.
Reply
#8

Ok so how should one call this library() function or is it just a bug/broken?
Reply
#9

(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.
Reply
#10

If you named your library CI_formgenerator then remove the CI_
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB