[ic] require field with variable field name

Stefan Hornburg Racke interchange-users@interchange.redhat.com
Thu Mar 21 04:15:02 2002


"Russ Mann" <tech@khouse.org> writes:

> Hello List,
> 
> What I needed to do is require that an Email To field be an email address if
> and only if it a product is a gift certificate.
> 
> Here's how to do it, in case anyone ever has need:
> 
> Inside the [if items], but outside the [item-list]
> <!-- [scratchd require_me_fields] -->
> 
> 
> Part of the [item-list] code.
> [if-item-field gift_cert]
> <!--
> [perl interpolate=1]
> if ($Scratch->{require_me_fields} !~ "emailto_[item-increment]") {
> $Scratch->{require_me_fields} = $Scratch->{require_me_fields} . "
> emailto_[item-increment]";
> }
> [/perl]
> -->
> <tr bgcolor="[item-alternate
> 2]#eeeeee[else]#c0c0c0[/else][/item-alternate]">
> <td colspan="5" align="left">
> <table border="0" cellspacing="0" cellpadding="2" width="100%"><tr>
> <td width="100"><font __FFACE__ size="1" ><b>[error
> name=emailto_[item-increment] std_label="E-Mail To"
> required=1]:</b></font></td>
> <td>[if !value emailto_[item-increment]][value name=emailto_[item-increment]
> set="Not Set" hide=1][/if]
> <input type="text" name="emailto_[item-increment]" value="[value
> emailto_[item-increment]]" size="85" maxlength="255">
> </td></tr><tr>
> <td width="100"><font __FFACE__ size="1" ><b>[error
> name=giftnote_[item-increment] std_label="Personal Note"
> required=0]:</b></font></td>
> <td><input type="text" name="giftnote_[item-increment]" value="[value
> giftnote_[item-increment]]" size="85" maxlength="255"></td>
> </tr></table>
> </td></tr>
> [/if-item-field]
> 
> 
> 
> Then, in profiles.order, in the checkout profile:
> 
> 
> [if scratch require_me_fields]
> [loop arg="[scratch require_me_fields]"]
> [loop-code] = required
> [loop-code] = email
> [/loop]
> [/if]

Seems overly complicated to me. Have you tried to put the
[item-list] loop into the profile ? That might work
much better IMHO.

Ciao
        Racke

-- 
Think of it !

For projects and other business stuff please refer to COBOLT NetServices
(URL: http://www.cobolt.net; Email: info@cobolt.net; Phone: 0041-1-3884400)