Welcome Guest, Not a member yet? Register   Sign In
Form Validation, validation->error_string not displaying
#1

[eluser]freakish777[/eluser]
So following the instructions here, when I don't fill out the form correctly I don't see the error string above my re-loaded form. However when I switch:

Code:
if ($this->validation->run() == FALSE)
{
   $this->load->view('myForm');
}

to:
Code:
if ($this->validation->run() == FALSE)
{
   echo $this->validation->error_string;
}

I do in fact see the error string.

Has anyone else experienced something similar? Is there some type of scope issue on the variables? I would imagine once they're set they'd be accessible in any of the views you load them in later...
#2

[eluser]JayTee[/eluser]
Now that there's a new version of CI out, you'll probably want to indicate which one you're using.
#3

[eluser]freakish777[/eluser]
1.6.3

Is this a past bug that's now resolved?
#4

[eluser]JayTee[/eluser]
I don't know if it's a bug that was resolved, per se; the form validation has been re-done in 1.7.0. You may want to check it out.

On the other hand, I would suggest that you avoid checking for falsehood; it's not the best programming practice if you can avoid it. I usually do it this way:
Code:
if ($this->validation->run())
{
  //process form
}
else
{
  echo $this->validation->error_string;
}
You can see that it's just slightly different, but more readable.

Anyway, the reloaded form should have this in it:
Code:
<?PHP echo $this->validation->error_string ?>
at the top of the form. I don't know what your view looks like; but I'd start there.
#5

[eluser]freakish777[/eluser]
[quote author="JayTee" date="1225094693"]I would suggest that you avoid checking for falsehood[/quote]

Can $this->validation->run() resolve to anything besides true or false (I assume it can't)? If not then it's largely inconsequential whether I check for true or false, and it doesn't affect readability at all (for me at least,I'm the only one maintaining the code for the site in question).

Quote:Anyway, the reloaded form should have this in it:
Code:
<?PHP echo $this->validation->error_string ?>
at the top of the form. I don't know what your view looks like; but I'd start there.

It does, just like the example I linked to in my first post. That's why I'm confused as to why I'm not seeing anything. I'll see if CI 1.7.0 helps.
#6

[eluser]lmv4321[/eluser]
Please post your controller code.




Theme © iAndrew 2016 - Forum software by © MyBB