* Kip Lawrence <kip at jkcrafts.com> [2003/11/21 11:50]:
> The problem with using:
> 
> [% cgi.params.carton != 'on' %]
> 
> is that I can't tell if the carton checkbox really was unselected. The
> above code would be true if I did unselect it. Or it would also be true
> if I hit the page by typing the URL into my browser. I need to be able
> to tell that for sure the checkbox was unselected.

The browser doesn't have to send the carton parameter if it wasn't
selected.  I think they all do, but I'm pretty sure it isn't mandated.

> Is there no way to tell if a key exists in a hash? Even if it contains
> ''.

The exists vmethod will help you:

  [% IF cgi.params.exists('carton') AND
        cgi.params.carton != 'on' %]
      ....

> Or is it that the cgi module always returns '' instead of undef if a key
> doesn't exists in cgi.params.

cgi.params returns a hash, which will autovivify undefined keys and
return undef.  TT does the rest, i.e., treating undef as a string will
turn it into ''.  cgi.params.carton will *always* be at least an empty
string, unless you are running under debugging with DEBUG_STASH enabled
(then it raises an exception).

(darren)

-- 
Time is an illusion, lunchtime doubly so.
    -- Ford Prefect

Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to