Welcome Guest, Not a member yet? Register   Sign In
Form Validation: How to wrap all errors in a single container?
#1

[eluser]momsenmeister[/eluser]
Hi,

how is it possible to wrap all form validation errors in a single container?
For example, how to display all form validation errors as a list?

The error delimiter only allows to wrap each error separately.

Thx!
#2

[eluser]mi6crazyheart[/eluser]
As far as i know each error is wrap by HTML "Paragraph" tag. So, i don't think it cause any problem. If u want u can also manually keep all the errors in container...

Ex:
Code:
if(validation_errors())
{
  echo '<div class="ValidationError">';
  echo validation_errors();
  echo '</div>';
}
#3

[eluser]michalsn[/eluser]
Maybe I misunderstood you, but you can use
Code:
&lt;?php echo validation_errors(); ?&gt;
http://ellislab.com/codeigniter/user-gui...l#tutorial

//edit
@mi6crazyheart was a bit faster
#4

[eluser]momsenmeister[/eluser]
Thx so far, but that's not quite what I'm looking for.
Solution of mi6crazyheart is okay, but I want to define the output globally.
So maybe a helper is the best solution?

View:
Code:
&lt;? echo wrapped_validation_errors(); ?&gt;

Helper:
Code:
function wrapped_validation_errors()
{
  $out = '';

  if (validation_errors())
  {
    $out = '<div class="ValidationError">'.
           validation_errors().
           '</div>';
  }

  return $out;
}

Would that be a clean solution, or can you think of a better one?




Theme © iAndrew 2016 - Forum software by © MyBB