[Zope3-checkins] CVS: Zope3/src/zope/app/browser/form - widget.py:1.26
Steve Alexander
steve@cat-box.net
Fri, 4 Apr 2003 10:39:59 -0500
Update of /cvs-repository/Zope3/src/zope/app/browser/form
In directory cvs.zope.org:/tmp/cvs-serv24225/src/zope/app/browser/form
Modified Files:
widget.py
Log Message:
The RadioWidget was not producing valid xhtml transitional.
The label had a 'for' attribute that didn't have a matching id.
I've fixed this by removing the 'for' on the label for the general case,
and including a 'for' that points to the id of the 'field' div when
you ask the widget to render a row.
=== Zope3/src/zope/app/browser/form/widget.py 1.25 => 1.26 ===
--- Zope3/src/zope/app/browser/form/widget.py:1.25 Wed Mar 26 10:26:21 2003
+++ Zope3/src/zope/app/browser/form/widget.py Fri Apr 4 10:39:28 2003
@@ -578,6 +578,20 @@
def renderSelectedItem(self, index, text, value, name, cssClass):
return self._renderItem(index, text, value, name, cssClass, True)
+ def label(self):
+ ts = getService(self.context.context, "Translation")
+ title = ts.translate("zope", self.title, context=self.request)
+ if title is None:
+ title = self.title
+ # radio field's label isn't "for" anything
+ return title
+
+ def row(self):
+ return ('<div class="label"><label for="%s">%s</label></div>'
+ '<div class="field" id="%s">%s</div>' % (
+ self.name, self.label(), self.name, self())
+ )
+
class MultiItemsWidget(ItemsWidget):
"""A widget with a number of items that has multiple selectable items."""
default = []