Welcome Guest, Not a member yet? Register   Sign In
Undefined property: Form::$form_validation
#1

[eluser]joky[/eluser]
Hi everyone,

I'm new to CI and to this forum so thanks in advance for accepting me with my bad english.

Well, I tryed to make a form with validation. Something very simple and it did'nt work so, I took a look at the user guide and I copy/paste the 3 files needed.

The only thing I changes is the views folder.

But I got the same error :

Quote:A PHP Error was encountered
Severity: Notice
Message: Undefined property: Form::$form_validation
Filename: controllers/form.php
Line Number: 11

And here is my form.php

Code:
<?php

class Form extends CI_Controller {

    function index()
    {
        $this->load->helper(array('form', 'url'));

        $this->load->library('form_validation');

        if ($this->form_validation->run() == FALSE)
        {
            $this->load->view('tests/myform');
        }
        else
        {
            $this->load->view('tests/formsuccess');
        }
    }
}
?>

So line 11 is :

Code:
if ($this->form_validation->run() == FALSE)

I hope some one will be able to help me soon.

Regards Smile
#2

[eluser]Nur Cholikul Anwar[/eluser]
PLease copy your tests/myform and tests/formsuccess
#3

[eluser]joky[/eluser]
Hello,

No problem, these are the views like in the user guide :

tests/formsuccess.php
Code:
<html>
<head>
<title>My Form</title>
</head>
<body>

<h3>Your form was successfully submitted!</h3>

<p>&lt;?php echo anchor('form', 'Try it again!'); ?&gt;</p>

&lt;/body&gt;
&lt;/html&gt;

tests/myform.php
Code:
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;My Form&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;?php echo validation_errors(); ?&gt;

&lt;?php echo form_open('form'); ?&gt;

<h5>Username</h5>
&lt;input type="text" name="username" value="" size="50" /&gt;

<h5>Password</h5>
&lt;input type="text" name="password" value="" size="50" /&gt;

<h5>Password Confirm</h5>
&lt;input type="text" name="passconf" value="" size="50" /&gt;

<h5>Email Address</h5>
&lt;input type="text" name="email" value="" size="50" /&gt;

<div>&lt;input type="submit" value="Submit" /&gt;&lt;/div>

&lt;/form&gt;

&lt;/body&gt;
&lt;/html&gt;

Regards
#4

[eluser]Nur Cholikul Anwar[/eluser]
Please check what file /codeigniter/system/libraries/Form_validation.php and /codeigniter/system/helper/form_helper.php is exist??
#5

[eluser]joky[/eluser]
yes they both exist...
i don't understand why copy/paste from user guide doesn't work...
#6

[eluser]InsiteFX[/eluser]
Add this in the top of your controller/index method
Code:
// Enable Profiler.
    $this->output->enable_profiler(TRUE);

And see what it says!

InsiteFX
#7

[eluser]joky[/eluser]
Code:
&lt;?php

class Form extends CI_Controller {

    function index()
    {
        $this->output->enable_profiler(true);
        $this->load->helper(array('form', 'url'));

        $this->load->library('form_validation');

        if ($this->form_validation->run() == FALSE)
        {
            $this->load->view('tests/myform');
        }
        else
        {
            $this->load->view('tests/formsuccess');
        }
    }
}
?&gt;

Same output....

Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined property: Form::$form_validation

Filename: controllers/form.php

Line Number: 12

If it can help, this is the log output (all messages)

Quote:&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?&gt;

DEBUG - 2011-04-26 14:11:17 --&gt; Config Class Initialized
DEBUG - 2011-04-26 14:11:17 --&gt; Hooks Class Initialized
DEBUG - 2011-04-26 14:11:17 --&gt; Utf8 Class Initialized
DEBUG - 2011-04-26 14:11:17 --&gt; UTF-8 Support Enabled
DEBUG - 2011-04-26 14:11:17 --&gt; URI Class Initialized
DEBUG - 2011-04-26 14:11:17 --&gt; Router Class Initialized
DEBUG - 2011-04-26 14:11:17 --&gt; Output Class Initialized
DEBUG - 2011-04-26 14:11:17 --&gt; Security Class Initialized
DEBUG - 2011-04-26 14:11:17 --&gt; Input Class Initialized
DEBUG - 2011-04-26 14:11:17 --&gt; Global POST and COOKIE data sanitized
DEBUG - 2011-04-26 14:11:17 --&gt; Language Class Initialized
DEBUG - 2011-04-26 14:11:17 --&gt; Loader Class Initialized
DEBUG - 2011-04-26 14:11:17 --&gt; Helper loaded: url_helper
DEBUG - 2011-04-26 14:11:17 --&gt; Helper loaded: form_helper
DEBUG - 2011-04-26 14:11:17 --&gt; Database Driver Class Initialized
DEBUG - 2011-04-26 14:11:17 --&gt; Controller Class Initialized
DEBUG - 2011-04-26 14:11:17 --&gt; Controller Class Initialized
DEBUG - 2011-04-26 14:11:17 --&gt; Form Validation Class Initialized
ERROR - 2011-04-26 14:11:17 --&gt; Severity: Notice --&gt; Undefined property: Form::$form_validation /home/joky/fb/bk/application/controllers/form.php 12
#8

[eluser]InsiteFX[/eluser]
Try changing your controller name to a different one then Form and
see if the error goes away!

InsiteFX
#9

[eluser]joky[/eluser]
Hello, thx again for trying to help me.

I changes controller name but i knew it couldn't work because i got the same mistake on another controller.

Error :

Quote:A PHP Error was encountered
Severity: Notice
Message: Undefined property: Ugtester::$form_validation
Filename: controllers/ugtester.php
Line Number: 12

File : ugtester.php
Uri : http://fb.localhost/index.php/ugtester
File Code

Code:
&lt;?php

class Ugtester extends CI_Controller {

    function index()
    {
        $this->output->enable_profiler(true);
        $this->load->helper(array('form', 'url'));

        $this->load->library('form_validation');

        if ($this->form_validation->run() == FALSE)
        {
            $this->load->view('tests/myform');
        }
        else
        {
            $this->load->view('tests/formsuccess');
        }
    }
}
?&gt;

But maybe my CI is broken, i just dl it and try to make it work and when i try to load a Model this time, I got exactly the same error...

In a week i didn't code anything working with CI...
#10

[eluser]joky[/eluser]
Well, i found the bug....
An External library in autoload i didn't use....

Sorry for all this stuff and thx for help




Theme © iAndrew 2016 - Forum software by © MyBB