Rendering checkbox "checked" from request

Sebastian Ware <[email protected]> Wed, 25 Oct 2006 11:08:42 +0200
Newsgroups gmane.comp.web.zope.formulator.devel
Message-ID <[email protected]>
Hi!

A quick one:

How do I render a Checkbox as checked when using render from request?

I use Formulator forms to update PropertyFolder objects  
(Abracadabra...). The forms contain among other things two  
checkboxes. I use the ZopeLABS ZPT recipe to render the form from a  
request. String-fields and listfields etc. render correctly with the  
value passed in the request set, however, the checkbox doesn't render  
checked.

I have found this code in the Widget.py and wonder if I can change  
something to make this work porperly:

(Potential offending code: checked=None)

     def render(self, field, key, value, REQUEST):
         """Render checkbox.
         """
         if value:
             return render_element("input",
                                   type="checkbox",
                                   name=key,
                                   css_class=field.get_value 
('css_class'),
                                   checked=None,
                                   extra=field.get_value('extra'))
         else:
             return render_element("input",
                                   type="checkbox",
                                   name=key,
                                   css_class=field.get_value 
('css_class'),
                                   extra=field.get_value('extra'))




mvh sebastian