In my interface I have Bool fields, say e. g. for invitation

  class IAdr(Interface)
    invitation = Bool(

Now when rendering the following edit-form

  class AdrEditForm(form.EditForm):
      fields = field.Fields(IAdr)

I get radio-boxes for invitation like so:

  (*) yes ( ) no

(by the way: this can also been seen in z3c.formdemo on the
"All widgets" page widgets.html)

Well nice - after all this reflects the behaviour of boolean
values: they can be either yes (True) or no (False).

Actually I preferred formlibs behaviour of rendering checkboxes
for Bools though, something like:


I. e. a single checkbox that can either be checked [v] or not [ ]
should suffice for a boolean value. - This is shorter than
the radio buttons and just as good.

Now I was hoping that this was implemented in z3c.form.browser.checkbox

  class AdrEditForm(form.EditForm):
      fields = field.Fields(IAdr)

      def MyFieldWidget(field, req):
        return widget.FieldWidget(field, checkbox.CheckBoxWidget(req))

      fields['invitation'].widgetFactory = MyFieldWidget

However I get *two* checkboxes now

  [ ] yes [ ] no

for the one boolean field invitation - that's not exactly what
I was looking for: *one* checkbox should be enough for a Bool field
- and what should happen by the way, if I check both boxes  
([v] yes [v] no)?

I think there should be an easy way to do this. This is very
common after all. - Any hints? Have I overlooked something?


Zope3-users mailing list

Reply via email to