--- a/web/views/autoform.py Thu Feb 18 11:08:00 2010 +0100
+++ b/web/views/autoform.py Thu Feb 18 12:13:36 2010 +0100
@@ -169,14 +169,14 @@
:attr etype: the entity type being created in the inline form
"""
__regid__ = 'inline-creation'
- __select__ = (match_kwargs('peid', 'rtype')
+ __select__ = (match_kwargs('peid', 'petype', 'rtype')
& specified_etype_implements('Any'))
+ _select_attrs = InlineEntityEditionFormView._select_attrs + ('petype',)
@property
def removejs(self):
entity = self._entity()
- ttype = self._cw.entity_from_eid(self.peid).__regid__
- rdef = entity.e_schema.rdef(self.rtype, neg_role(self.role), ttype)
+ rdef = entity.e_schema.rdef(self.rtype, neg_role(self.role), self.petype)
card= rdef.role_cardinality(self.role)
# when one is adding an inline entity for a relation of a single card,
# the 'add a new xxx' link disappears. If the user then cancel the addition,
@@ -209,7 +209,7 @@
:attr card: the cardinality of the relation according to role of `peid`
"""
__regid__ = 'inline-addnew-link'
- __select__ = (match_kwargs('peid', 'rtype')
+ __select__ = (match_kwargs('peid', 'petype', 'rtype')
& specified_etype_implements('Any'))
_select_attrs = InlineEntityCreationFormView._select_attrs + ('card',)
@@ -220,8 +220,8 @@
divid = "addNew%s%s%s:%s" % (self.etype, self.rtype, self.role, self.peid)
self.w(u'<div class="inlinedform" id="%s" cubicweb:limit="true">'
% divid)
- js = "addInlineCreationForm('%s', '%s', '%s', '%s', '%s')" % (
- self.peid, self.etype, self.rtype, self.role, i18nctx)
+ js = "addInlineCreationForm('%s', '%s', '%s', '%s', '%s', '%s')" % (
+ self.peid, self.petype, self.etype, self.rtype, self.role, i18nctx)
if self.pform.should_hide_add_new_relation_link(self.rtype, self.card):
js = "toggleVisibility('%s'); %s" % (divid, js)
__ = self._cw.pgettext
@@ -710,8 +710,9 @@
if self.should_display_add_new_relation_link(rschema, formviews, card):
addnewlink = self._cw.vreg['views'].select(
'inline-addnew-link', self._cw,
- etype=ttype, rtype=rschema, role=role,
- peid=self.edited_entity.eid, pform=self, card=card)
+ etype=ttype, rtype=rschema, role=role, card=card,
+ peid=self.edited_entity.eid,
+ petype=self.edited_entity.e_schema, pform=self)
formviews.append(addnewlink)
allformviews += formviews
return allformviews
@@ -771,7 +772,9 @@
"""
yield self._cw.vreg['views'].select('inline-creation', self._cw,
etype=ttype, rtype=rschema, role=role,
- peid=self.edited_entity.eid, pform=self)
+ peid=self.edited_entity.eid,
+ petype=self.edited_entity.e_schema,
+ pform=self)
## default form ui configuration ##############################################