[form, renderer] closes #1787234: [form] onsubmit interpolated by the form renderer, it shouldn't
--- a/web/views/formrenderers.py Wed Jun 29 18:28:55 2011 +0200
+++ b/web/views/formrenderers.py Wed Jun 29 18:29:13 2011 +0200
@@ -37,7 +37,6 @@
from warnings import warn
-from logilab.common import dictattr
from logilab.mtconverter import xml_escape
from cubicweb import tags, uilib
@@ -193,7 +192,7 @@
if form.domid:
attrs.setdefault('id', form.domid)
if form.onsubmit:
- attrs.setdefault('onsubmit', form.onsubmit % dictattr(form))
+ attrs.setdefault('onsubmit', form.onsubmit)
if form.cssstyle:
attrs.setdefault('style', form.cssstyle)
if form.cssclass:
--- a/web/views/forms.py Wed Jun 29 18:28:55 2011 +0200
+++ b/web/views/forms.py Wed Jun 29 18:29:13 2011 +0200
@@ -132,7 +132,6 @@
needs_js = ('cubicweb.ajax.js', 'cubicweb.edition.js',)
needs_css = ('cubicweb.form.css',)
action = None
- onsubmit = "return freezeFormButtons('%(domid)s');"
cssclass = None
cssstyle = None
cwtarget = None
@@ -146,6 +145,15 @@
"""true if the form needs enctype=multipart/form-data"""
return any(field.needs_multipart for field in self.fields)
+ def _get_onsubmit(self):
+ try:
+ return self._onsubmit
+ except AttributeError:
+ return "return freezeFormButtons('%(domid)s');" % dictattr(self)
+ def _set_onsubmit(self, value):
+ self._onsubmit = value
+ onsubmit = property(_get_onsubmit, _set_onsubmit)
+
def add_media(self):
"""adds media (CSS & JS) required by this widget"""
if self.needs_js: