[ic] Follow up to FormAction question

Randy Moore ramoore@axion-it.net
Mon, 11 Sep 2000 19:24:03 -0400


At 07:04 PM 9/11/00 -0400, you wrote:
>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.


Agreed.  I'm pretty good at extending an example, but I don't really 
understand how the userland Perl & MV Packages work together.


>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.

Actually, this is the point of my first post this afternoon, the 
$CGI->{key} form doesn't work either.

This very simple example (taken mostly from the docs) does not properly set 
the nextpage:

      FormAction item_profile <<EOR
      sub {
                 $CGI->{mv_nextpage} = 'index';
                 return(1);
      }
      EOR




> >
> >          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');


But, as I understand it, this would cause and mv_order_items to be 
processed BEFORE the order profile is evaluated. And that is exactly the 
problem I'm trying to get around.

Thanks for the suggestions.

Randy Moore
Axion Information Technologies, Inc.

email     ramoore@axion-it.net
phone   301-408-1200
fax        301-445-3947