Welcome Guest, Not a member yet? Register   Sign In
error on form view, trying to display validation_errors()
#1

[eluser]CodeIgniterNoob[/eluser]
Im following the instructions here http://ellislab.com/codeigniter/user-gui...ation.html in the beggining, building the form and the views. But, my form view keeps getting this error Fatal error: Call to undefined function validation_errors() in /.../.../.../.../system/application/views/form.php on line 3

I can build this form my way, but I want to try doing it using CI. Can anyone help please. Im following the tutorial line for line.
#2

[eluser]CodeIgniterNoob[/eluser]
The form:

Code:
<html>
<head>
<title>My Form</title>
</head>
<body>

<?php echo validation_errors(); ?>

<?php echo form_open('form'); ?>

<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;


Success page:
Code:
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;My Form&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;

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

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

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

Controller:

Code:
&lt;?php

class Form extends Controller {
    
    function index()
    {
        $this->load->helper(array('form', 'url'));
        
        $this->load->library('form_validation');
                
        if ($this->form_validation->run() == FALSE)
        {
            $this->load->view('myform');
        }
        else
        {
            $this->load->view('formsuccess');
        }
    }
}
?&gt;

Just like in the online manual. http://www.ellislab.com/codeigniter/user...ation.html

And I still get the error on my form page.
Fatal error: Call to undefined function validation_errors() in /.../.../.../.../system/application/views/form.php on line 3

Even on my own validation errors I get this error "Call to undefined function form_error()" I bet its something really small that Im forgetting to do...
#3

[eluser]cahva[/eluser]
Well that is strange. It seems that the form helper is not loaded althought it does show that you have loaded it in the code. Does that function exist in helpers/form_helper.php file? Also enable logging and see from the log that the helper is indeed loaded.
#4

[eluser]CodeIgniterNoob[/eluser]
Nope, Im still getting the same error. Im using the latest CI version. I created a test database and followed everything exactly. Still getting this error: Call to undefined function validation_errors()

And the function validation_errors() does not exist in the Form_validation.php file.
#5

[eluser]Armchair Samurai[/eluser]
Just as a quick note, the Form Validation library automatically loads the Form helper, so there's no need to load it individually. The validation_errors() function is in the form_helper.php file.

In regards to your specific problem, CINoob, in your example, you haven't added any validation rules. There have been some reports in the forum that not setting rules for fields caused the Form Validation library to throw errors - try adding rules for all your fields and see if that helps.
#6

[eluser]CodeIgniterNoob[/eluser]
Ok, Im not exactly sure what happened to my initial download (1.7)... but a huge chunk of code in my form_helper.php file was gone. I never even opened that file. I downloaded the CI again, and there they were, all the missing functions... Im sorry to waste everyones time.
#7

[eluser]E1M2[/eluser]
Is the new form_validation class *really* working for 1.7?

I am not getting any visible error messages via form_error method.
Tried a fresh install of the system folder, recreated a whole new form, even took a fresh copy from trunk.

$this->form_validation->run() returns appropriate results both true and false dependent on set_rules() it's just not display the specific errors with form_error(). Ugh.... what are your thoughts?

thanks!
#8

[eluser]CodeIgniterNoob[/eluser]
hey E1M2, it worked great for me, just look at this page http://ellislab.com/codeigniter/user-gui...ation.html and make sure that your form_helper.php file has all the necessary functions. I had alot of problems getting validations to work, but thats because half the functions were missing in that file, and I still dont know how it happened.
#9

[eluser]E1M2[/eluser]
I just found that there's something happening with form_validation for those of us using the Matchbox library.
Going to check see what the deal is there. I'll post an update here on a resolve.
#10

[eluser]E1M2[/eluser]
found a short-term solution to the problem here for reference:
http://ellislab.com/forums/viewthread/95755/




Theme © iAndrew 2016 - Forum software by © MyBB