[forms] Add autocomplete attribute for formrenderers
If you set form.autocomplete = False, the form renderer
in the open form tag will add the html option 'autocomplete=off'.
It allows to disable the functionality of some browsers to fill in
some forms automatically (for instance a profile with login/password)
Closes #3747294
--- a/web/views/formrenderers.py Fri Apr 11 17:43:26 2014 +0200
+++ b/web/views/formrenderers.py Mon Apr 14 23:00:19 2014 +0200
@@ -202,6 +202,8 @@
attrs.setdefault('class', form.cssclass)
if form.cwtarget:
attrs.setdefault('cubicweb:target', form.cwtarget)
+ if not form.autocomplete:
+ attrs.setdefault('autocomplete', 'off')
return '<form %s>' % uilib.sgml_attributes(attrs)
def close_form(self, form, values):
--- a/web/views/forms.py Fri Apr 11 17:43:26 2014 +0200
+++ b/web/views/forms.py Mon Apr 14 23:00:19 2014 +0200
@@ -111,6 +111,9 @@
:attr:`fieldsets_in_order`
sequence of fieldset names , to control order
+ :attr:`autocomplete`
+ set to False to add 'autocomplete=off' in the form open tag
+
**Generic methods**
.. automethod:: cubicweb.web.form.Form.field_by_name(name, role=None)
@@ -160,6 +163,7 @@
form_buttons = None
form_renderer_id = 'default'
fieldsets_in_order = None
+ autocomplete = True
@property
def needs_multipart(self):