set tabindex tls-sprint
authorsylvain.thenault@logilab.fr
Wed, 11 Mar 2009 11:34:46 +0100
branchtls-sprint
changeset 1055 b87222b63950
parent 1054 434e098f6c76
child 1056 be43d95ebb52
set tabindex
web/form.py
--- a/web/form.py	Wed Mar 11 11:34:15 2009 +0100
+++ b/web/form.py	Wed Mar 11 11:34:46 2009 +0100
@@ -258,12 +258,16 @@
     needs_js = ()
     needs_css = ()
     setdomid = True
+    settabindex = True
     
-    def __init__(self, attrs=None, setdomid=None):
+    def __init__(self, attrs=None, setdomid=None, settabindex=None):
         self.attrs = attrs or {}
         if setdomid is not None:
             # override class's default value
             self.setdomid = setdomid
+        if settabindex is not None:
+            # override class's default value
+            self.settabindex = settabindex
 
     def add_media(self, form):
         """adds media (CSS & JS) required by this widget"""
@@ -284,6 +288,8 @@
         attrs = dict(self.attrs)
         if self.setdomid:
             attrs['id'] = form.context[field]['id']
+        if self.settabindex:
+            attrs['tabindex'] = form.req.next_tabindex()
         return name, values, attrs
 
 class Input(FieldWidget):
@@ -324,6 +330,7 @@
 class HiddenInput(Input):
     type = 'hidden'
     setdomid = False # by default, don't set id attribute on hidden input
+    settabindex = False
     
 class ButtonInput(Input):
     type = 'button'