[ic] Follow up to FormAction question
Mike Heins
mikeh@minivend.com
Mon, 11 Sep 2000 19:04:05 -0400
Quoting Randy Moore (ramoore@axion-it.net):
> Hi again,
>
> Sorry for following up my own post, but I forgot to explain why I'm trying
> to use FormAction. Maybe there is a better way. Any suggestions?
Your problem is that you apparently don't understand that the Perl you
are writing is:
under Safe protection to some degree
the same as the embedded Perl in the [calc] tag.
called from the package Vend::Interpolate.
If you want to write some docs that will elucidate that, you are welcome;
I hope that we will be producing an Interchange programming guide shortly
which will detail some of these things.
>
> I'm actually trying to use a 'profile' to validate form fields before a
> customer is allowed to add an item to their basket. In other words, unless
> the customer provides good values in a form, they can't add this product to
> their basket.
>
> I couldn't find a simple way to do this, so I decided to create a
> FormAction that would evaluate a 'profile' and only if the profile
> succeeded, process any items ordered on the form. I took the logic for
> this (with many changes) from the 'submit' formaction defined in /bin/minivend.
>
> Here is the real FormAction I want to use:
>
> FormAction item_profile <<EOR
> sub {
> my($missing,$next,$status,$final);
>
> # Set shopping cart if necessary
> # Vend::Items is tied, remember!
> $Vend::Items = $CGI::values{mv_cartname}
> if $CGI::values{mv_cartname};
Here is your problem. You are mixing $CGI::values{key} with $CGI->{key}. The
second is appropriate in this context.
>
> if (defined $CGI->{mv_order_profile}) {
> ($status,$final,$missing) =
> check_order($CGI->{mv_order_profile});
The check_order() function will not be available to you. You can
do:
$CGI->{mv_todo} = 'submit';
$Tag->update('process');
> }
> else {
> $status = 1;
> }
>
> if($status) {
> add_items() if defined
> $CGI->{mv_order_item};
add_items is not available. You can do $Tag->update('values');
>
> $CGI->{mv_nextpage} = $CGI->{mv_successpage}
> if $CGI->{mv_successpage};
> $CGI->{mv_nextpage} = $CGI->{mv_orderpage}
> if ! $CGI->{mv_nextpage};
> }
>
> else {
> $CGI::values{mv_nextpage} = $::Values->{mv_failpage}
> if $::Values->{mv_failpage};
> $CGI::values{mv_nextpage} = find_special_page('needfield')
> if ! $CGI::values{mv_nextpage};
find_special_page is not available. Hard code this and set it to
'../special_pages/needfield'.
> }
> return(1);
> }
> EOR
>
--
Akopia, Inc., 131 Willow Lane, Floor 2, Oxford, OH 45056
phone +1.513.523.8220 fax 7501 <heins@akopia.com>
Friends don't let friends use Outlook. -- Bob Blaylock