Display form validation errors in an unordered list in a proper way. - 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: Display form validation errors in an unordered list in a proper way. (/showthread.php?tid=37321) |
Display form validation errors in an unordered list in a proper way. - El Forum - 01-05-2011 [eluser]Bramme[/eluser] Hey everybody I'm trying to display my form validation errors in a pretty way, but find it difficult to do this elegantly. At the moment, I just do Code: $validation_errors = validation_errors('<li>', '</li>'); Any suggestions? Display form validation errors in an unordered list in a proper way. - El Forum - 01-05-2011 [eluser]Victor Michnowicz[/eluser] This is the code I place in my view: Code: <?php if (validation_errors()): ?> Display form validation errors in an unordered list in a proper way. - El Forum - 01-05-2011 [eluser]Eric Barnes[/eluser] Yep I do it the same as @elvicmic Display form validation errors in an unordered list in a proper way. - El Forum - 01-05-2011 [eluser]Victor Michnowicz[/eluser] Another thing I "discovered" recently was this: Code: $config = array( So now the error will include a link to the element that has an error (Assuming you name your inputs appropriately). You can even include some JavaScript (or :target) to help highlight the field. Display form validation errors in an unordered list in a proper way. - El Forum - 01-05-2011 [eluser]Bramme[/eluser] [quote author="elvicmic" date="1294281755"]This is the code I place in my view: Code: <?php if (validation_errors()): ?> I guess I could do that, but that would mean I have to put the <ul> tags in my feedback message, which could also accept other things besides <li> tags. At the moment I think I'll just start creating a buttload of helper functions. The thing is that I'm putting html everywhere at the moment (my main library, my controller, my views), I'm not even comfortable with that. And if I have to start putting html in my views too... I should also start using a language file now, while there aren't that many language strings littered everywhere yet. |