[ic] Changing "required field" formatting from bold to using a trailing asterisk.

Ethan Rowe ethan at endpoint.com
Wed Jan 19 07:03:50 EST 2005

Chuck Adams wrote:

>I found the post referenced below at
>html but my Interpolate.pm (Interchange v5.2) looks A LOT different than
>the 2003-04-25 version.   Can someone provide guidance in updating
>Interpolate.pm and after.cfg to accomplish the same thing in Fedora Core
>1/Interchange 5.2?  Any ideas are welcome.
>Thanks in advance
>This one gave me a bit of a run-around, but I did finally figure it
>out.  If you like the default "bold" fields, then you should be set to
>go using the error tag with the "std_label" attribute.
>I think it makes the form harder to read with some labels bolded and
>others not, so I changed mine.  In etc/after.cfg, I added this line:
>Variable MV_ERROR_STD_LABEL <label for="{NAME}" class="error">{LABEL}
><i>(%s)</i></label>[else]<label for="{NAME}">{LABEL}{REQUIRED
>Note the tabs between "Variable" and "MV_ERROR_STD_LABEL" and the
>value.  Also, I modified Interpolate.pm a little to add the "{NAME}"
>replacement.  The diff for this is:
>--- lib/Vend/Interpolate.pm-dist        2003-04-26 13:32:31.000000000
>+++ lib/Vend/Interpolate.pm     2003-04-25 23:31:52.000000000 -0500
>@@ -6513,6 +6513,9 @@
>                }
>                $text =~ s/{LABEL}/$opt->{std_label}/g;
>                $text =~ s/{REQUIRED\s+([^}]*)}/$opt->{required} ? $1 :
>+        if (defined $opt->{name}) {
>+                       $text =~ s/{NAME}/$opt->{name}/g;
>+        }
>                $err =~ s/\s+$//;
>        }
>        $text = '' unless defined $text;
>Capstone Technology
>Chuck Adams
>chuck.adams at capstone-tech.com 
>P.O. Box 369
>Cedar Park, TX 78630 
>tel: 512-343-8891
>interchange-users mailing list
>interchange-users at icdevgroup.org
The tag code moved out of Interpolate.pm and into 

The section relevant to your needs:
       if($opt->{std_label}) {
                # store the error label in user's session for later
                # possible use in [error show_label=1] calls
                $Vend::Session->{errorlabels}{$var} = $opt->{std_label};
                if($text) {
                        # do nothing
                elsif(defined $::Variable->{MV_ERROR_STD_LABEL}) {
                        $text = $::Variable->{MV_ERROR_STD_LABEL};
                else {
                        $text = <<EOF;
[else]{REQUIRED <B>}{LABEL}{REQUIRED </B>}[/else]
                $text =~ s/{LABEL}/$opt->{std_label}/g;
                $text =~ s/{REQUIRED\s+([^}]*)}/$opt->{required} ? $1 : 
                $err =~ s/\s+$//;
        $text = '' unless defined $text;
        $text .= '%s' unless $text =~ /\%s/;
        $text = pull_else($text, $found_error);
        return sprintf($text, $err);

As you can see, you may provide a template in the variable 
MV_ERROR_STD_LABEL, or you can provide a template via the "text" 
attribute when you call the tag:
[error name=some_field std_label="Some Field" text=|<span 
class="error_text">{LABEL}: You blew it!  Here's why -- (%s)</span>
[else]<span class="label{REQUIRED _required}">{LABEL}[/else]

The label you give to the error tag goes in at {LABEL}, the error 
message goes in at (%s) when appropriate, and {REQUIRED <some_content>} 
is replaced by <some_content> if the "required" attribute is set.  The 
[else]...[/else] block is used when no error is found, while the other 
portion is used when an error is present.

In your specific case, you would set up the else portion as:
[else]{LABEL} {REQUIRED *}[/else]

Fortunately there's no need to hack the core to do this; just set up 
that catalog variable if you want this to be consistent through your 

Ethan Rowe
End Point Corporation
ethan at endpoint.com

More information about the interchange-users mailing list