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

Steve Alexander steve@cat-box.net
Thu, 20 Feb 2003 10:36:39 -0500


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

Modified Files:
	widget.py 
Log Message:
After discussion with Limi, if a ui widget's type is given as an
attribute, add that type + '_type' as a css class.


=== Zope3/src/zope/app/browser/form/widget.py 1.15 => 1.16 ===
--- Zope3/src/zope/app/browser/form/widget.py:1.15	Thu Feb 20 09:56:42 2003
+++ Zope3/src/zope/app/browser/form/widget.py	Thu Feb 20 10:36:34 2003
@@ -650,10 +650,24 @@
     attr_list = []
 
     # special case handling for cssClass
+    cssClass = ''
     if 'cssClass' in kw:
-        if kw['cssClass'] != "":
-            attr_list.append('class="%s"' % kw['cssClass'])
+        if kw['cssClass']:
+            cssClass = kw['cssClass']
         del kw['cssClass']
+
+    # If the 'type' attribute is given, append this plus '_type' as a
+    # css class. This allows us to do subselector stuff in css without
+    # necessarily having a browser that supports css subselectors.
+    # This is important if you want to style radio inputs differently than
+    # text inputs.
+    cssWidgetType = kw.get('type')
+    if cssWidgetType:
+        cssWidgetType += '_type'
+    else:
+        cssWidgetType = ''
+    if cssWidgetType or cssClass:
+        attr_list.append('class="%s"' % ' '.join((cssClass, cssWidgetType)))
 
     if 'style' in kw:
         if kw['style'] != '':