[Zope-dev] z3c.form - extraction from sequence widget

Marius Gedminas marius at gedmin.as
Thu Aug 28 11:45:58 EDT 2008


On Thu, Aug 28, 2008 at 05:26:20PM +0200, Hermann Himmelbauer wrote:
> Am Donnerstag 28 August 2008 10:14:11 schrieb Martin Aspeli:
> > What about the case when you have a list of options of which you need to
> > chose one or more? In that case, ticking none is a validation error.
> 
> Yes, in your case this should give a validation error. However, the case where 
> someone uses a checkbox for a True/False operation is at least as common. And 
> if "no ticking" gives a validation error, this would prevent using checkboxes 
> for this case. Moreover, a checkbox is typically used to represent a "Bool" 
> schema (by default it's a choice widget, I think), so that fits well, I 
> think. 
> 
> My suggestion would be to:
> 
> - Create some schema field, e.g. "MultipleChoice":
> 
> colors = MutlipleChoice(title='Colors', values=['red', 'green', 'blue'], 
> default=['green', 'blue'], required=True)

colors = Set(type=u"Choose your favourite colors",
             value_type=Choice(values=['red', 'green', 'blue']),
             min_length=1)

> - Register a widget for this field, which is then rendered as a bunch of 
> checkboxes.

I think there is a multi-selection widget based on checkboxes, that
works on Sets of Choices.  It's not the default widget (the default is a
multi-selection list box), and while it is registered as being valid for
sets, it always tries to store a list in the content object.

I'm writing from memory, so I may have gotten some details wrong.

Marius Gedminas
-- 
The typewriter was invented by Hungarian immigrant Qwert Yuiop, who left his
"signature" on the keyboard.
        -- "Kim"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.zope.org/pipermail/zope-dev/attachments/20080828/330eee40/attachment.bin 


More information about the Zope-Dev mailing list