Discussion:
[FE-discuss] bugfix? to htmlfill.render with force_defaults=False
Jon Nelson
2009-10-08 17:18:22 UTC
Permalink
I learned that htmlfill.render ignores <option> elements entirely if
force_defaults is False.

Here is a (working but probably wrong) patch to fix it, as applied to trunk.

diff --git a/formencode/htmlfill.py b/formencode/htmlfill.py
index b725f00..deb85eb 100644
--- a/formencode/htmlfill.py
+++ b/formencode/htmlfill.py
@@ -490,6 +490,13 @@ class FillingParser(RewritingParser):
self.add_key(self.in_select)
else:
self.del_attr(attrs, 'selected')
+ else:
+ value = self.defaults.get(self.in_select)
+ current = self.get_attr(attrs, 'value')
+ selected = self.get_attr(attrs, 'selected')
+ if selected is None and current is not None and value
is not None:
+ if self.selected_multiple(value, current):
+ self.set_attr(attrs, 'selected', 'selected')
self.write_tag('option', attrs)
self.skip_next = True
--
Jon
Hao Lian
2009-10-08 23:44:25 UTC
Permalink
Hello all!

On Thu, Oct 8, 2009 at 1:18 PM, Jon Nelson
Post by Jon Nelson
I learned that htmlfill.render ignores <option> elements entirely if
force_defaults is False.
I think this is the bug w31rd0 filed. It seems to be a bug in
test_htmlfill.py as well, which w31rd0's patch covers. It'd be great
if his patch could be looked at and maybe checked into trunk. (If
formencode needs extra man-hours, I could provide some in order to
shepherd this bug.)

http://sourceforge.net/tracker/?func=detail&aid=2799713&group_id=91231&atid=596416
Loading...