Display form validation errors in an unordered list in a proper way. |
[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?
[eluser]Victor Michnowicz[/eluser]
This is the code I place in my view: Code: <?php if (validation_errors()): ?>
[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.
[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. |
Welcome Guest, Not a member yet? Register Sign In |