4.25. error

4.25.1. Summary

Parameters: name

Positional parameters in same order.

The attribute hash reference is passed to the subroutine after the parameters as the last argument. This may mean that there are parameters not shown here.

Must pass named parameter interpolate=1 to cause interpolation.

Invalidates cache: no

Called Routine:

ASP-like Perl call:

         name => VALUE,


    $Tag->error($name, $ATTRHASH);
    [error name other_named_attributes]
Parameters Description Default
Attributes Default
interpolate (reparse) No
Invalidates cache no
Container tag No
Has Subtags No
Nests Yes

Tag expansion example:

    [error name]
    TODO: (tag result)

ASP-like Perl call:

   $Tag->error(  { name => VALUE_name
}, $body  );

or similarly with positional parameters,

    $Tag->error(name, $attribute_hash_reference, $body);

4.25.2. Description

    [error var options]
        var is the error name, e.g. "session"

The [error ...] tag is designed to manage form variable checking for the Interchange submit form processing action. It works in conjunction with the definition set in mv_order_profile, and can generate error messages in any format you desire.

If the variable in question passes order profile checking, it will output a label, by default bold text if the item is required, or normal text if not (controlled by the <require> parameter. If the variable fails one or more order checks, the error message will be substituted into a template and the error cleared from the user's session.

(Below is as of 4.03, the equivalent in 4.02 is [if type=explicit compare="[error all=1 keep=1]"] ... [/if].)

To check errors without clearing them, you can use the idiom:

    [if errors]
        There were errors in your form submission.
        [error all=1 show_error=1 joiner="<BR>"]

The options are: all=1

Display all error messages, not just the one referred to by <var>. The default is only display the error message assigned to <var>.

text=<optional string to embed the error message(s) in>

place a "%s" somewhere in 'text' to mark where you want the error message placed, otherwise it's appended on the end. This option also implies show_error. joiner=char

Character used to join multiple error messages. Default is '\n', a newline. keep=1

keep=1 means don't delete the error messages after copy; anything else deletes them. show_error=1

show_error=1 means return the error message text; otherwise just the number of errors found is returned. show_label=1

show_label=1 causes the field label set by a previous [error] tag's std_label attribute (see below) to be included as part of the error message, like this:

First Name: blank

If no std_label was set, the variable name will be used instead. This can also be used in combination with show_var to show both the label and the variable name.

show_label was added in 4.7.0. show_var=1

show_var=1 includes the name of the variable the error was found in as part of the error message, like this:

email: 'bob#nothing,net' not a valid email address std_label

std_label=<label string for error message>

used with 'required' to display a standardized error format. The HTML formatting can be set via the global variable MV_ERROR_STD_LABEL with the default being:


where {LABEL} is what you set std_label to and %s is substituted with the error message. This option can not be used with the text= option. required=1

Specifies that this is a required field for formatting purposes. In the std_label format, it means the field will be bolded. If you specify your own label string, it will insert HTML anywhere you have {REQUIRED: HTML}, but only when the field is required. name