CodeIgniter Forums
Help displaying errors with Form Validation - 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: Help displaying errors with Form Validation (/showthread.php?tid=20080)



Help displaying errors with Form Validation - El Forum - 06-27-2009

[eluser]theQco[/eluser]
I'd like to be able to display the form validation errors at the top of the page and then have each form element (like input) outlined in red or have an arrow next to it to tie the two together.

I haven't found a way to do this yet. All I have found is the echo form_error() which places the error next to the form element.

Any help would be greatly appreciated.

Thanks!

Brian


Help displaying errors with Form Validation - El Forum - 06-27-2009

[eluser]TheFuzzy0ne[/eluser]
You can use form_error() to set a class for your element if there is an error:

Code:
<label for="text" &lt;?php echo (form_error('text')) ? ' class="error"' : ''; ?&gt;>Text:</label><br />
&lt;input type="text" name="text" value="&lt;?php echo set_value('text'); ?&gt;" /&gt;



Help displaying errors with Form Validation - El Forum - 06-27-2009

[eluser]theQco[/eluser]
Perfect. That is exactly what I was looking for.

Thanks!