use a counter of displayed inlined forms stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 02 Jul 2009 14:51:37 +0200
branchstable
changeset 2247 9dbbe6a4c9b0
parent 2246 e89c15221a8a
child 2248 cbf043a2134a
use a counter of displayed inlined forms
web/views/editforms.py
web/views/formrenderers.py
--- a/web/views/editforms.py	Thu Jul 02 14:44:23 2009 +0200
+++ b/web/views/editforms.py	Thu Jul 02 14:51:37 2009 +0200
@@ -368,8 +368,13 @@
         divid = '%s-%s-%s' % (peid, rtype, entity.eid)
         title = self.schema.rschema(rtype).display_name(self.req, role)
         removejs = self.removejs % (peid, rtype,entity.eid)
+        countkey = '%s_count' % rtype
+        try:
+            self.req.data[countkey] += 1
+        except:
+            self.req.data[countkey] = 1
         self.w(form.form_render(divid=divid, title=title, removejs=removejs,
-                                **kwargs))
+                                counter=self.req.data[countkey], **kwargs))
 
     def add_hiddens(self, form, entity, peid, rtype, role):
         # to ease overriding (see cubes.vcsfile.views.forms for instance)
--- a/web/views/formrenderers.py	Thu Jul 02 14:44:23 2009 +0200
+++ b/web/views/formrenderers.py	Thu Jul 02 14:51:37 2009 +0200
@@ -500,7 +500,7 @@
         w(u'<div class="iformBody">')
         values['removemsg'] = self.req.__('remove this %s' % form.edited_entity.e_schema)
         w(u'<div class="iformTitle"><span>%(title)s</span> '
-          '#<span class="icounter">1</span> '
+          '#<span class="icounter">%(counter)s</span> '
           '[<a href="javascript: %(removejs)s;noop();">%(removemsg)s</a>]</div>'
           % values)
         # cleanup values