bugfix? to htmlfill.render with force_defaults=False
Jon Nelson <jnelson+formencode-l78HVRKxS1/[email protected]> Thu, 8 Oct 2009 12:18:22 -0500
| Newsgroups | gmane.comp.python.formencode |
|---|---|
| Message-ID | <[email protected]> |
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
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference