CodeIgniter Forums
Form Confusion, How to Properly Display Form Errors? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Form Confusion, How to Properly Display Form Errors? (/showthread.php?tid=6188)



Form Confusion, How to Properly Display Form Errors? - El Forum - 02-17-2008

[eluser]Chris.Campbell[/eluser]
Could someone please show me a code example of how to properly display form errors with CodeIgniter, yet keeping the already entered form data intact. I am able to accomplish this without the framework, using an error array, a foreach loop, counter, and having some post defaults. How would one go about this using CI? Thanks!


Form Confusion, How to Properly Display Form Errors? - El Forum - 02-17-2008

[eluser]Michael Wales[/eluser]
Code:
<?= $this->validation->error_string; ?>

<?= form_open('user/login'); ?>
<input type="text" name="username" value="<?= $this->validation->username; ?>" />
<input type="submit" value="Go" />
<?= form_close(); ?>



Form Confusion, How to Properly Display Form Errors? - El Forum - 02-17-2008

[eluser]Chris.Campbell[/eluser]
Ok first can you explain the $this->validation->error_string part more, and how I would go about populating that with data.

Also, I am using the template parser.


Form Confusion, How to Properly Display Form Errors? - El Forum - 02-18-2008

[eluser]kgill[/eluser]
Read the user guide, specifically the notes for the validation class, if you're still confused ask again.

- K


Form Confusion, How to Properly Display Form Errors? - El Forum - 02-18-2008

[eluser]jorre[/eluser]
I managed to do this just by using the code from the user guide, so try that out first.


Form Confusion, How to Properly Display Form Errors? - El Forum - 02-18-2008

[eluser]Chris.Campbell[/eluser]
Oh wow, thanks guys, I did not even see a validation class in the user guide.