web/views/editforms.py
changeset 4164 119a374c5eb4
parent 4160 3fbdeef9a610
child 4167 73e649a7797d
equal deleted inserted replaced
4163:b2747ed057e6 4164:119a374c5eb4
   408 
   408 
   409     def init_form(self, form, entity):
   409     def init_form(self, form, entity):
   410         """customize your form before rendering here"""
   410         """customize your form before rendering here"""
   411         super(CopyFormView, self).init_form(form, entity)
   411         super(CopyFormView, self).init_form(form, entity)
   412         if entity.eid == self.newentity.eid:
   412         if entity.eid == self.newentity.eid:
   413             form.form_add_hidden(eid_param('__cloned_eid', entity.eid),
   413             form.add_hidden(eid_param('__cloned_eid', entity.eid),
   414                                  self.copying.eid)
   414                             self.copying.eid)
   415         for rschema, role in form.editable_attributes():
   415         for rschema, role in form.editable_attributes():
   416             if not rschema.final:
   416             if not rschema.final:
   417                 # ensure relation cache is filed
   417                 # ensure relation cache is filed
   418                 rset = self.copying.related(rschema, role)
   418                 rset = self.copying.related(rschema, role)
   419                 self.newentity.set_related_cache(rschema, role, rset)
   419                 self.newentity.set_related_cache(rschema, role, rset)
   534         """to ease overriding (see cubes.vcsfile.views.forms for instance)"""
   534         """to ease overriding (see cubes.vcsfile.views.forms for instance)"""
   535         iid = 'rel-%s-%s-%s' % (self.peid, self.rtype, entity.eid)
   535         iid = 'rel-%s-%s-%s' % (self.peid, self.rtype, entity.eid)
   536         #  * str(self.rtype) in case it's a schema object
   536         #  * str(self.rtype) in case it's a schema object
   537         #  * neged_role() since role is the for parent entity, we want the role
   537         #  * neged_role() since role is the for parent entity, we want the role
   538         #    of the inlined entity
   538         #    of the inlined entity
   539         form.form_add_hidden(name=str(self.rtype), value=self.peid,
   539         form.add_hidden(name=str(self.rtype), value=self.peid,
   540                              role=neg_role(self.role), eidparam=True, id=iid)
   540                         role=neg_role(self.role), eidparam=True, id=iid)
   541 
   541 
   542     def keep_entity(self, form, entity):
   542     def keep_entity(self, form, entity):
   543         if not entity.has_eid():
   543         if not entity.has_eid():
   544             return True
   544             return True
   545         # are we regenerating form because of a validation error ?
   545         # are we regenerating form because of a validation error ?