[Zope] Multiple selection property as list

Phil Harris phil.harris@zope.co.uk
Tue, 13 Mar 2001 23:11:24 -0000


If, on your form, you use something like this:

<input type=radio name="takeaction:list">

Then the returned value will *always* be a list, no need then for your
check.

Phil
----- Original Message -----
From: "Joh Johannsen" <jojo@farm9.com>
To: "Dieter Maurer" <dieter@handshake.de>
Cc: "Alexander James Tucker" <alex.tucker@totalise.co.uk>; <zope@zope.org>
Sent: Tuesday, March 13, 2001 11:06 PM
Subject: Re: [Zope] Multiple selection property as list


> Actually if by "Multipel selection property" you mean checkboxes on a
> form, if you check only one, you get a string.  If you check more than
> one, you get a list.
>
> This is what I do to detect that (but I'll bet someone knows a better
> way!)
>
> On my form I have 25 checkboxes with the name "takeaction", each with a
> different value.  The ".len(takeaction[0])" gives me a 1 if the
> "takeaction" is a string, otherwise it gives me the length of the first
> value, which is never 1 in my case, otherwise this technique would not
> work.
>
> <dtml-if expr="_.len(takeaction[0])==1">
>  <dtml-call "REQUEST.set('takeaction',(takeaction,))">
> </dtml-if>
>
> After this, the variable can be treated as a list even if it comes in as
> a string.
>
> Regards,
>
> JJ
>
>
> Dieter Maurer wrote:
> >
> > Alexander James Tucker writes:
> >  > ....
> >  > In
> >  >   <dtml-if expr="'Some group' in groups">
> >  > "groups" is a string,
> >  > in
> >  >     <dtml-in groups>
> >  > it is a list
> >  > ....
> > I cannot believe this!
> > Both "groups" are resolved in the same way.
> >
> > Dieter
> >
> > _______________________________________________
> > Zope maillist  -  Zope@zope.org
> > http://lists.zope.org/mailman/listinfo/zope
> > **   No cross posts or HTML encoding!  **
> > (Related lists -
> >  http://lists.zope.org/mailman/listinfo/zope-announce
> >  http://lists.zope.org/mailman/listinfo/zope-dev )
>
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )