Accumulate error messages

Summary

Make a variable for error messages. Append all messages to that variable.

Situation

You want to show all relevant error messages for a transaction at the same time.

Provides

A variable containing all the error messages you want to show.

Action

Make a variable, like $errorMessages. Initialize it to MT:

  • @$errorMessages@ = '';

Append errors to the variable as they happen. Put each message in its own p, or separate them with brs:

  • @$errorMessages@ .= "Sorry, Dave, I can't let you do that.<br>\n";

.= means "append to the end of."

Show error messages in a container div. Or something.

  • <div class="error-message-container">
  •   <?= $errorMessages ?>
  • </div>
Where referenced