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

Sidnei da Silva sidnei at x3ng.com.br
Sat Aug 16 14:24:09 EDT 2003


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

Modified Files:
	widget.py 
Log Message:
Make required fields have a required CSS class to help with styling

=== Zope3/src/zope/app/browser/form/widget.py 1.50 => 1.51 ===
--- Zope3/src/zope/app/browser/form/widget.py:1.50	Fri Aug 15 20:42:49 2003
+++ Zope3/src/zope/app/browser/form/widget.py	Sat Aug 16 13:23:35 2003
@@ -290,14 +290,18 @@
             self.name, self._tooltip(title, self.context.description),
             )
 
+    def labelClass(self):
+        return self.context.required and "label required" or "label"
+
     def row(self):
         if self.error:
             error = zapi.getView(self.error, 'snippet', self.request)()
-            return '<div class="label">%s</div><div class="field">%s</div>' \
-                '<div class="error">%s</div>' % (self.label(), self(), error)
+            return '<div class="%s">%s</div><div class="field">%s</div>' \
+                '<div class="error">%s</div>' % (self.labelClass(),
+                                                 self.label(), self(), error)
         else:
-            return '<div class="label">%s</div><div class="field">%s</div>' % (
-                self.label(), self()
+            return '<div class="%s">%s</div><div class="field">%s</div>' % (
+                self.labelClass(), self.label(), self()
                 )
 
 class DisplayWidget(BrowserWidget):
@@ -937,9 +941,9 @@
         return title
 
     def row(self):
-        return ('<div class="label"><label for="%s">%s</label></div>'
+        return ('<div class="%s"><label for="%s">%s</label></div>'
                 '<div class="field" id="%s">%s</div>' % (
-                self.name, self.label(), self.name, self())
+                self.labelClass(), self.name, self.label(), self.name, self())
                 )
 
 class MultiItemsWidget(ItemsWidget):




More information about the Zope3-Checkins mailing list