[editforms] fix missing __maineid, avoid double submit through submit button, say no to locals() tls-sprint
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Wed, 29 Apr 2009 19:48:27 +0200
branchtls-sprint
changeset 1559 c4d4851bd18b
parent 1541 ddddbb748355
child 1560 7dd2a81b8bc8
[editforms] fix missing __maineid, avoid double submit through submit button, say no to locals()
web/views/editforms.py
--- a/web/views/editforms.py	Wed Apr 29 12:51:43 2009 +0200
+++ b/web/views/editforms.py	Wed Apr 29 19:48:27 2009 +0200
@@ -103,22 +103,22 @@
             self.w(value)
             return
         eid = entity.eid
-        edit_key = make_uid('%s-%s' % (rtype, eid))
-        divid = 'd%s' % edit_key
-        reload = dumps(reload)
-        buttons = [SubmitButton(stdmsgs.BUTTON_OK, cwaction='apply'),
+        divid = 'd%s' % make_uid('%s-%s' % (rtype, eid))
+        event_data = {'divid' : divid, 'eid' : eid, 'rtype' : rtype, 'reload' : dumps(reload)}
+        buttons = [SubmitButton(stdmsgs.BUTTON_OK),
                    Button(stdmsgs.BUTTON_CANCEL,
                           onclick="cancelInlineEdit(%s,\'%s\',\'%s\')" % (eid, rtype, divid))]
         form = self.vreg.select_object('forms', 'edition', self.req, self.rset,
                                        row=row, col=col, form_buttons=buttons,
                                        domid='%s-form' % divid, action='#',
                                        cssstyle='display: none',
-                                       onsubmit=self.onsubmit % locals())
+                                       onsubmit=self.onsubmit % event_data)
+        form.form_add_hidden(u'__maineid', entity.eid)
         renderer = FormRenderer(display_label=False, display_help=False,
                                 display_fields=(rtype,), button_bar_class='buttonbar',
                                 display_progress_div=False)
         self.w(tags.div(value, klass='editableField', id=divid,
-                        ondblclick=self.ondblclick % locals()))
+                        ondblclick=self.ondblclick % event_data))
         self.w(form.form_render(renderer=renderer))