[Zope] Multiple selection property as list

Joh Johannsen jojo@farm9.com
Tue, 13 Mar 2001 15:06:45 -0800


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 )