[forms] fix multiple edit bug introduced by changeset cebdf8ee5ad7 stable
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Tue, 05 Jan 2010 22:11:37 +0100
branchstable
changeset 4210 9d9be21640ac
parent 4209 8712d699beb2
child 4212 ab6573088b4a
[forms] fix multiple edit bug introduced by changeset cebdf8ee5ad7 Changeset cebdf8ee5ad7 assumed that edited entity was either explicitly passed to the form or found in first row / first col of the resultset because of the one_line_rset() selector. But one_line_rset() is actually trickier : the selector returns 1 if the resultset has more than one row **if** an explicit row is specified during selection process. This is exactly what is done in the 'muledit' form : for row in xrange(len(self.rset)): form = self.vreg['forms'].select('edition', self.req, rset=self.rset, row=row, #... This changeset thus takes row in consideration to find edited entity if 'row' was explcitly specified.
web/views/forms.py
--- a/web/views/forms.py	Tue Jan 05 18:28:27 2010 +0100
+++ b/web/views/forms.py	Tue Jan 05 22:11:37 2010 +0100
@@ -268,15 +268,15 @@
     internal_fields = FieldsForm.internal_fields + ('__type', 'eid', '__maineid')
     domid = 'entityForm'
 
-    def __init__(self, req, rset=None, *args, **kwargs):
+    def __init__(self, req, rset=None, row=None, col=None, *args, **kwargs):
         # entity was either explicitly specified or we have a one line rset
         if 'entity' in kwargs:
             self.edited_entity = kwargs.pop('entity')
         else:
-            self.edited_entity = rset.get_entity(0, 0)
+            self.edited_entity = rset.get_entity(row or 0, col or 0)
             self.edited_entity.complete()
         msg = kwargs.pop('submitmsg', None)
-        super(EntityFieldsForm, self).__init__(req, rset, *args, **kwargs)
+        super(EntityFieldsForm, self).__init__(req, rset, row, col, *args, **kwargs)
         self.form_add_hidden('__type', eidparam=True)
         self.form_add_hidden('eid')
         if kwargs.get('mainform', True): # mainform default to true in parent