[Zope3-Users] MultiCheckBoxWidget and formlib

2006-05-26 Thread Mats Nordgren
Could anyone give me a hint on setting up a MultiCheckBoxWidget with
formlib?


This is what I got:

class IMySchema(Interface):
  multichoice = Set(
title=_('Pick one or many'),
value_type = Choice(values=['one', 'two', 'three']))

class MyEditForm(form.EditForm):
  form_fields = form.Fields(IMySchema)
  form_fields['multichoice'].custom_widget = 


What in the world do I do to get this to work?

Any help greatly appreciated.

Sincerely,

Mats

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] MultiCheckBoxWidget and formlib

2006-05-26 Thread Tom Dossis
Mats Nordgren wrote:
 Could anyone give me a hint on setting up a MultiCheckBoxWidget with
 formlib?
 
 
 This is what I got:
 
 class IMySchema(Interface):
   multichoice = Set(
 title=_('Pick one or many'),
 value_type = Choice(values=['one', 'two', 'three']))
 
 class MyEditForm(form.EditForm):
   form_fields = form.Fields(IMySchema)
   form_fields['multichoice'].custom_widget = 
 
 
 What in the world do I do to get this to work?

I've done something similar along the lines of...

class IMySchema(Interface):
  multichoice = Set(
title=_('Pick one or many'),
value_type=SimpleVocabulary.fromItems([
  (_(One), one),
  (_(Two), two),
  (_(Three, three),
  ])
Maybe try zope.app.form.browser.MultiSelectWidget ..
It requires 3 args in its constructor which you can wrap for formlib, e.g.

class MyMultiSelectWidget(MultiSelectWidget):

  def __init__(self, field, request):
super(MyMultiSelectWidget, self).__init__(
  field, field.value_type.vocabulary, request)

Then ..

  form_fields['multichoice'].custom_widget=MyMultiSelectWidget

You could also look at the alternative widget..

  zope.app.form.browser.itemswidgets.MultiCheckBoxWidget



___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users