set __maineid in EntityFieldsForm
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 05 Jun 2009 10:18:40 +0200
changeset 2049 b9baedffeb8b
parent 2048 5e4d1433b90b
child 2050 ce184fdb1e56
set __maineid in EntityFieldsForm
web/views/editforms.py
web/views/forms.py
--- a/web/views/editforms.py	Fri Jun 05 10:03:16 2009 +0200
+++ b/web/views/editforms.py	Fri Jun 05 10:18:40 2009 +0200
@@ -119,7 +119,6 @@
         else:
             form = self._build_relation_form(entity, value, rtype, role,
                                              row, col, vid, default)
-        form.form_add_hidden(u'__maineid', entity.eid)
         renderer = self.vreg.select_object('formrenderers', 'base', self.req,
                                       entity=entity,
                                       display_label=False, display_help=False,
@@ -194,7 +193,7 @@
 
     def init_form(self, form, entity):
         """customize your form before rendering here"""
-        form.form_add_hidden(u'__maineid', entity.eid)
+        pass
 
     def form_title(self, entity):
         """the form view title"""
@@ -356,8 +355,7 @@
         """fetch and render the form"""
         form = self.vreg.select_object('forms', 'edition', self.req, None,
                                        entity=entity, form_renderer_id='inline',
-                                       mainform=False,
-                                       copy_nav_params=False)
+                                       mainform=False, copy_nav_params=False)
         self.add_hiddens(form, entity, peid, rtype, role)
         divid = '%s-%s-%s' % (peid, rtype, entity.eid)
         title = self.schema.rschema(rtype).display_name(self.req, role)
--- a/web/views/forms.py	Fri Jun 05 10:03:16 2009 +0200
+++ b/web/views/forms.py	Fri Jun 05 10:18:40 2009 +0200
@@ -268,9 +268,10 @@
         self.form_add_hidden('__type', eidparam=True)
         self.form_add_hidden('eid')
         if msg:
+            self.form_add_hidden('__message', msg)
+        if kwargs.get('mainform'):
+            self.form_add_hidden(u'__maineid', self.edited_entity.eid)
             # If we need to directly attach the new object to another one
-            self.form_add_hidden('__message', msg)
-        if not self.is_subform:
             for linkto in self.req.list_form_param('__linkto'):
                 self.form_add_hidden('__linkto', linkto)
                 msg = '%s %s' % (msg, self.req._('and linked'))