changeset 4878:dffe83c636a7

Small HTML output updates to facilitate OpenID. Allow disabling form select controls and add specific id attribute to forms (for targeting with javascript).
author Rowan Kerr <rowan@stasis.org>
date Fri, 15 May 2009 14:17:23 -0400
parents 273ec9b3bf7d
children c19a628febc1
files MoinMoin/util/web.py MoinMoin/widget/html.py
diffstat 2 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/util/web.py	Sun May 10 19:52:46 2009 +0200
+++ b/MoinMoin/util/web.py	Fri May 15 14:17:23 2009 -0400
@@ -25,7 +25,7 @@
         return result
 
 
-def makeSelection(name, values, selectedval=None, size=1, multiple=False):
+def makeSelection(name, values, selectedval=None, size=1, multiple=False, enabled=True):
     """ Make a HTML <select> element named `name` from a value list.
         The list can either be a list of strings, or a list of
         (value, label) tuples.
@@ -33,7 +33,7 @@
         `selectedval` is the value that should be pre-selected.
     """
     from MoinMoin.widget import html
-    result = html.SELECT(name=name, size="%d" % int(size), multiple=multiple)
+    result = html.SELECT(name=name, size="%d" % int(size), multiple=multiple, disabled=not enabled)
     for val in values:
         if not isinstance(val, type(())):
             val = (val, val)
@@ -44,7 +44,7 @@
 
     return result
 
-def makeMultiSelection(name, values, selectedvals=None, size=5):
+def makeMultiSelection(name, values, selectedvals=None, size=5, enabled=True):
     """Make a HTML multiple <select> element with named `name` from a value list.
 
     The list can either be a list of strings, or a list of (value, label) tuples.
@@ -52,7 +52,7 @@
 
     """
     from MoinMoin.widget import html
-    result = html.SELECT(name=name, size="%d" % int(size), multiple=True)
+    result = html.SELECT(name=name, size="%d" % int(size), multiple=True, disabled=not enabled)
     for val in values:
         if not isinstance(val, type(())):
             val = (val, val)
--- a/MoinMoin/widget/html.py	Sun May 10 19:52:46 2009 +0200
+++ b/MoinMoin/widget/html.py	Fri May 15 14:17:23 2009 -0400
@@ -308,6 +308,7 @@
         'onreset': None,
         'onsubmit': None,
         'target': None,
+        'id': None,
     }
     _DEFAULT_ATTRS = {
         'method': 'POST',
@@ -551,6 +552,7 @@
         'onfocus': None,
         'size': None,
         'tabindex': None,
+        'id': None,
     }
 
 class SMALL(CompositeElement):