Welcome Guest, Not a member yet? Register   Sign In
Problem with form_error() -function

Im new to CI and am currently learning the system and its capabilities. I was reading through the documentation and tried to implement a simple form with validation. The basic functionality seems to be working ok, but I cant seem to get any output from form_error() function to display field spesific errors? The $this->validation->error_string does work fine, however, and prints out all the errors at once. Whats wrong here?

Below is my code for the view.

<h1>Entering user data</h1>

   &lt;?php echo $this->validation->error_string;?&gt;
    &lt;?php echo form_open('validator');?&gt;
    &lt;?php echo '<p>'.form_error('firstname').'</p>'; ?&gt;
    <p>First Name &lt;input type="text" name="firstname" value="&lt;?php echo set_value('firstname');?&gt;" size="50" /&gt;&lt;/p>

    <p>&lt;input type="submit" value="Send Data" /&gt;&lt;/p>
And here's the controller:

class Validator extends Controller {

    function Validator() {

    // load controller parent


        // load 'url' helper


        // load 'form' helper

        // load 'validation' class



    function index() {

    // set validation rules



        // check if form has been submitted properly

        if ($this->validation->run()==FALSE) {

        // redisplay web form



        // display success web page

        else {





Thanks for any help.

It seems you are using the old deprecated validation library. You should be using the Form Validation library (no it's not confusing, really...)

Then a lot of helpers suddenly appear to be working, among which is form_error();

Again, it's not confusing... at all! ;-)

Theme © iAndrew 2016 - Forum software by © MyBB