Re: Checkboxes
"Mike Orr" <[email protected]>
| Newsgroups | gmane.comp.python.formencode |
|---|---|
| Message-ID | <[email protected]> |
On Jan 29, 2008 6:20 PM, A Monkey <[email protected]> wrote: > Does your checkbox have a "value" attribute? If your checkbox has a > "value" attribute then htmlfill will mark your checkbox as checked > only if the value specified in the defaults matches the "value" > attribute of the checkbox. If the checkbox has no "value" attribute, > then specifying a default value of True will leave it checked. Well, my real value is a Python boolean from SQLAlchemy.. My HTML has value="1". htmlfill changes the value to 'yes'. I'm usin g the StringBoolean validator. Originally I called it as: rslt = htmlfill.render(html, {'mycheckbox': record.field}) I had better luck when I changed it to: rslt = htmlfill.render(html, {'mycheckbox': record.field and "1" or ""}) But I'm still testing it. I think I also pre-set the initially-checked state, though I'd have to check that tomorrow. But I wish htmlfill would set the checkbox based on the boolean value, which seems like the most pythonic way to do it. I can try it without a value attribute and see if that works better. But then it won't be compatible with WebHelpers, which defaults to value='1'. -- Mike Orr <[email protected]> ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/