CodeIgniter Forums
Form validation form_error() custom message? - 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 validation form_error() custom message? (/showthread.php?tid=54012)



Form validation form_error() custom message? - El Forum - 08-18-2012

[eluser]deed02392[/eluser]
I have a table with basically inputs on multiple rows. Each row has array forms named like:

itemno[], upc[] etc.

Because there are a lot of fields across a few columns it's good to be able to tell the user exactly where the error is in a row, which I figured I could do with form_error. But the error message is much too long to fit in the cell with the field.

I wondered if I could just see if the field had an error or not and if it did, make an asterisk appear etc? Short of running the function and checking it doesn't return an empty string I can see it's not possible to do this with form_error().

Is there an alternative?

I know it doesn't make sense to list all the errors because then the user doesn't know which row the error is indicating there's a problem with, but it also doesn't make sense to just change the error string to an asterisk purely so when it appears in the cell it looks better.

Hope I made sense!


EDIT:

Hmm it seems form_error doesn't work like I expected either. Unlike set_value() which seems to be able to set the correct value back even for array'd form submissions, form_error() just gives an error in every case if any one item within it is invalid. Is there a way around this?