$this->validation->error_string; doesn't work in controller |
[eluser]KeyStroke[/eluser]
I'm trying to fetch the error string within my controller by using: Code: $this->validation->error_string; How do I make it work?
[eluser]Ahmed Nuaman[/eluser]
Check that you have included this: $this->load->library("validation");
[eluser]KeyStroke[/eluser]
I have. Otherwise it wouldn't have worked in the View.
[eluser]Ahmed Nuaman[/eluser]
Lol ok, hmmm, so you've run the validation: $this->validation->run() and set $this->validation->error_string to appear if the run() fails yeah? What are you doing with the error_string? Are you feeding it into another var?
[eluser]KeyStroke[/eluser]
Yes, it only runs when validation fails. I'm just echoing its value. I'm basically displaying a form's error messages in real-time using AJAX.
[eluser]KeyStroke[/eluser]
Thanks! that worked. What's the difference though between "echo" and "$this->output->set_output()"?
[eluser]Ahmed Nuaman[/eluser]
Right: If you've got 'compress output' on, all the content is gzipped and sent to the browser. This means your web site loads faster. What it means is that nothing can be sent to the browser until the script has been executed, so you can't use echos or prints. To find out more, read here: http://ellislab.com/codeigniter/user-gui...utput.html and http://ellislab.com/codeigniter/user-gui...tml#output |
Welcome Guest, Not a member yet? Register Sign In |