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"