add __domid hidden input in forms so that we can validate more than one form per page
authorFlorent <florent@secondweb.fr>
Thu, 04 Jun 2009 10:54:13 +0200
changeset 2045 bf0643d4ef36
parent 2005 e8032965f37a
child 2046 8fce2d25853c
add __domid hidden input in forms so that we can validate more than one form per page
web/views/basecontrollers.py
web/views/forms.py
--- a/web/views/basecontrollers.py	Fri May 29 14:19:30 2009 +0200
+++ b/web/views/basecontrollers.py	Thu Jun 04 10:54:13 2009 +0200
@@ -211,9 +211,11 @@
                 status, args = (False, '???')
         self.req.set_content_type('text/html')
         jsarg = simplejson.dumps( (status, args) )
+        domid = self.req.form.get('__domid', 'entityForm').encode(
+            self.req.encoding)
         return """<script type="text/javascript">
- window.parent.handleFormValidationResponse('entityForm', null, null, %s);
-</script>""" %  simplejson.dumps( (status, args) )
+ window.parent.handleFormValidationResponse('%s', null, null, %s);
+</script>""" %  (domid, simplejson.dumps( (status, args) ))
 
     def validation_error(self, err):
         self.req.cnx.rollback()
--- a/web/views/forms.py	Fri May 29 14:19:30 2009 +0200
+++ b/web/views/forms.py	Thu Jun 04 10:54:13 2009 +0200
@@ -62,6 +62,7 @@
         if submitmsg is not None:
             self.form_add_hidden('__message', submitmsg)
         self.context = None
+        self.form_add_hidden('__domid', self.domid)
         if 'domid' in kwargs:# session key changed
             self.restore_previous_post(self.session_key())