web/views/editforms.py
changeset 3536 f6c9a5df80fb
parent 3524 a3431f4e2f40
parent 3534 81cfec545e1b
child 3589 a5432f99f2d9
--- a/web/views/editforms.py	Tue Sep 29 15:58:44 2009 +0200
+++ b/web/views/editforms.py	Wed Sep 30 18:57:42 2009 +0200
@@ -16,6 +16,7 @@
 from logilab.mtconverter import xml_escape
 from logilab.common.decorators import cached
 
+from cubicweb import neg_role
 from cubicweb.selectors import (match_kwargs, one_line_rset, non_final_entity,
                                 specified_etype_implements, yes)
 from cubicweb.utils import make_uid
@@ -498,15 +499,13 @@
             counter=self.req.data[countkey], **kwargs))
 
     def add_hiddens(self, form, entity):
-        # to ease overriding (see cubes.vcsfile.views.forms for instance)
-        if self.keep_entity(form, entity):
-            if entity.has_eid():
-                rval = entity.eid
-            else:
-                rval = INTERNAL_FIELD_VALUE
-            form.form_add_hidden('edit%s-%s:%s' % (self.role[0], self.rtype, self.peid), rval)
-        form.form_add_hidden(name='%s:%s' % (self.rtype, self.peid), value=entity.eid,
-                             id='rel-%s-%s-%s'  % (self.peid, self.rtype, entity.eid))
+        """to ease overriding (see cubes.vcsfile.views.forms for instance)"""
+        iid = 'rel-%s-%s-%s' % (self.peid, self.rtype, entity.eid)
+        #  * str(self.rtype) in case it's a schema object 
+        #  * neged_role() since role is the for parent entity, we want the role
+        #    of the inlined entity
+        form.form_add_hidden(name=str(self.rtype), value=self.peid,
+                             role=neg_role(self.role), eidparam=True, id=iid)
 
     def keep_entity(self, form, entity):
         if not entity.has_eid():