[Zope3-checkins] CVS: Zope3/src/zope/app/browser/form - widget.py:1.8

Viktorija Zaksiene ryzaja@codeworks.lt
Wed, 15 Jan 2003 10:43:20 -0500


Update of /cvs-repository/Zope3/src/zope/app/browser/form
In directory cvs.zope.org:/tmp/cvs-serv22095/src/zope/app/browser/form

Modified Files:
	widget.py 
Log Message:
Updated all widgets to include id= attribute in the rendering output.  (This
is needed for <label> elements to work correctly, see the HTML4 spec)


=== Zope3/src/zope/app/browser/form/widget.py 1.7 => 1.8 ===
--- Zope3/src/zope/app/browser/form/widget.py:1.7	Thu Jan  9 09:13:04 2003
+++ Zope3/src/zope/app/browser/form/widget.py	Wed Jan 15 10:43:17 2003
@@ -95,6 +95,7 @@
         return renderElement(self.getValue('tag'),
                              type = self.getValue('type'),
                              name = self.name,
+                             id = self.name,
                              value = self._showData(),
                              cssClass = self.getValue('cssClass'),
                              extra = self.getValue('extra'))
@@ -103,6 +104,7 @@
         return renderElement(self.getValue('tag'),
                              type = 'hidden',
                              name = self.name,
+                             id = self.name,
                              value = self._showData(),
                              cssClass = self.getValue('cssClass'),
                              extra = self.getValue('extra'))
@@ -147,6 +149,7 @@
             return renderElement(self.getValue('tag'),
                                  type = self.getValue('type'),
                                  name = self.name,
+                                 id = self.name,
                                  checked = None,
                                  cssClass = self.getValue('cssClass'),
                                  extra = self.getValue('extra'))
@@ -154,6 +157,7 @@
             return renderElement(self.getValue('tag'),
                                  type = self.getValue('type'),
                                  name = self.name,
+                                 id = self.name,
                                  cssClass = self.getValue('cssClass'),
                                  size = self.getValue('displayWidth'),
                                  extra = self.getValue('extra'))
@@ -224,8 +228,8 @@
 
     def _select(self):
         selected = self._showData()
-        result = ['<select name="%s">'
-                  % (self.name)]
+        result = ['<select id="%s" name="%s">'
+                  % (self.name, self.name)]
 
         values = self.__values
 
@@ -250,6 +254,7 @@
             return renderElement(self.getValue('tag'),
                                  type = self.getValue('type'),
                                  name = self.name,
+                                 id = self.name,
                                  value = self._showData(),
                                  cssClass = self.getValue('cssClass'),
                                  style = self.style,
@@ -260,6 +265,7 @@
             return renderElement(self.getValue('tag'),
                                  type = self.getValue('type'),
                                  name = self.name,
+                                 id = self.name,
                                  value = self._showData(),
                                  cssClass = self.getValue('cssClass'),
                                  style = self.style,
@@ -324,6 +330,7 @@
     def __call__(self):
         return renderElement("textarea",
                              name = self.name,
+                             id = self.name,
                              cssClass = self.getValue('cssClass'),
                              rows = self.getValue('height'),
                              cols = self.getValue('width'),
@@ -352,6 +359,7 @@
             return renderElement(self.getValue('tag'),
                                  type = self.getValue('type'),
                                  name = self.name,
+                                 id = self.name,
                                  cssClass = self.getValue('cssClass'),
                                  size = self.getValue('displayWidth'),
                                  maxlength = displayMaxWidth,
@@ -360,6 +368,7 @@
             return renderElement(self.getValue('tag'),
                                  type = self.getValue('type'),
                                  name = self.name,
+                                 id = self.name,
                                  cssClass = self.getValue('cssClass'),
                                  size = self.getValue('displayWidth'),
                                  extra = self.getValue('extra'))
@@ -462,6 +471,7 @@
         renderedItems = self.renderItems(self._showData())
         return renderElement('select',
                               name = self.name,
+                              id = self.name,
                               cssClass = self.getValue('cssClass'),
                               size = self.getValue('size'),
                               contents = "\n".join(renderedItems),
@@ -495,6 +505,7 @@
                               type = "radio",
                               cssClass = cssClass,
                               name = name,
+                              id = name,
                               value = value) + text
 
     def renderSelectedItem(self, text, value, name, cssClass):
@@ -502,6 +513,7 @@
                               type="radio",
                               cssClass=cssClass,
                               name = name,
+                              id = name,
                               value = value,
                               checked = None) + text
 
@@ -560,6 +572,7 @@
         rendered_items = self.renderItems(self._showData())
         return renderElement('select',
                               name = self.name,
+                              id = self.name,
                               multiple = None,
                               cssClass = self.getValue('cssClass'),
                               size = self.getValue('size'),
@@ -593,6 +606,7 @@
                               type = "checkbox",
                               cssClass = cssClass,
                               name = name,
+                              id = name,
                               value = value) + text
 
     def renderSelectedItem(self, text, value, name, cssClass):
@@ -600,6 +614,7 @@
                               type = "checkbox",
                               cssClass = cssClass,
                               name = name,
+                              id = name,
                               value = value,
                               checked = None) + text