web/form.py
branchtls-sprint
changeset 1069 84bc7dce1876
parent 1068 04c745ce692e
child 1070 3bc7d4ebb543
--- a/web/form.py	Wed Mar 11 19:51:27 2009 +0100
+++ b/web/form.py	Wed Mar 11 19:51:50 2009 +0100
@@ -452,6 +452,21 @@
                    req._('calendar'), helperid) )
 
 
+class AjaxWidget(FieldWidget):
+    def __init__(self, wdgtype, inputid=None, **kwargs):
+        super(AjaxWidget, self).__init__(**kwargs)
+        self.attrs.setdefault('class', 'widget')
+        self.attrs.setdefault('cubicweb:loadtype', 'auto')
+        self.attrs['cubicweb:wdgtype'] = wdgtype
+        if inputid is not None:
+            self.attrs['cubicweb:inputid'] = inputid
+            
+    def render(self, form, field):
+        self.add_media(form)
+        name, values, attrs = self._render_attrs(form, field)
+        return tags.div(**attrs)
+
+
 # fields ############
 
 class Field(object):