Mailing List Archive

saving multiple values userdb.mail_list
hello all,

I'm sure there's several ways to solve this problem, but I can't see to
figure out any one of them. I'd like my users to be able to select one or
more mail lists to automatically join upon purchase.

Out of the box, interchange happily writes a yes/no value to
userdb.mail_list, based on the value of the mail_list form widget on
checkout.html.

If I try to submit multiple values for mail_list (using checkboxes or
<select multiple>), it only records the first value in userdb.

I tried changing the value of CGI->{mail_list} in profiles.order, but it
seems preferences are written before then.

So, any hints on how I can get both these form values into one field?

Thanks,

- Andrew

>>> Andrew Waegel Benevolent Technologies <<<
>>> 510 527 6116 asw@benevolent-tech.com <<<
saving multiple values userdb.mail_list [ In reply to ]
Quoting Andrew Waegel (andrew@benevolent-tech.com):
> hello all,
>
> I'm sure there's several ways to solve this problem, but I can't see to
> figure out any one of them. I'd like my users to be able to select one or
> more mail lists to automatically join upon purchase.
>
> Out of the box, interchange happily writes a yes/no value to
> userdb.mail_list, based on the value of the mail_list form widget on
> checkout.html.
>
> If I try to submit multiple values for mail_list (using checkboxes or
> <select multiple>), it only records the first value in userdb.

No, I don't believe this is true. It actually records value1\0value2\0\value3.

The answer is to filter that variable, either by setting
an input filter in the page or by:

Filter mail_list null_to_space

in catalog.cfg.

--
Akopia, Inc., 131 Willow Lane, Floor 2, Oxford, OH 45056
phone +1.513.523.7621 fax 7501 <heins@akopia.com>

Any man who is under 30, and is not liberal, has not heart; and any man
who is over 30, and is not a conservative, has not brains.
-- Winston Churchill
saving multiple values userdb.mail_list [ In reply to ]
>> If I try to submit multiple values for mail_list (using checkboxes or
>> <select multiple>), it only records the first value in userdb.
>
> No, I don't believe this is true. It actually records
> value1\0value2\0\value3.
>
> The answer is to filter that variable, either by setting
> an input filter in the page or by:
>
> Filter mail_list null_to_space
>
> in catalog.cfg.

Interesting. The multiple values were definately not being inserted into
mysql, but i'l bet somewhere else it was whacking off the value after the
first null.

I solved this problem with the first mv_click of my very own:

<input type=hidden name=mv_click value=Setprefs>
[set Setprefs]
[perl]
$CGI->{mail_list} = join(' ',@{$CGI_array->{'mail_list'}});
[/perl]
[/set]

...which massages mail_list into the form I want before it's saved to
userdb.

>>> Andrew Waegel Benevolent Technologies <<<
>>> 510 527 6116 asw@benevolent-tech.com <<<