[Zope] Form Variable

Paul Winkler pw_lists at slinkp.com
Wed Sep 22 14:51:22 EDT 2004


On Wed, Sep 22, 2004 at 02:20:40PM -0400, Asad Habib wrote:
> I have a form variable whose value is being passed to a DTML method upon
> form submission. In this DTML method, I use the form variable as input to
> a <dtml-in>. When this form variable is passed as a list(i.e. it contains
> multiple values), everything works fine. However, when this form variable
> is passed as a string(i.e. it contains a single value), <dtml-in>
> complains that it is being passed an input of the wrong type. Is there a
> way to detect whether this form variable is a list or string? Using the
> len function doesn't work because len works on both strings and lists.
> 
> One solution I have figured out uses a HTML hidden variable to set the
> form variable to a default value. This guarantees that the form variable
> is always a list since a minimum of 2 values are passed upon form
> submission. However, this is a hack and I'd rather use something more
> elegant.

In your form, append ":list" to the variable's name.
e.g.

<input type="text" name="my_variable:list"> ....

This is documented in the "Advanced Scripting" chapter of the
online zope book.

-- 

Paul Winkler
http://www.slinkp.com


More information about the Zope mailing list