45 if parent is not None: |
45 if parent is not None: |
46 return parent.rest_path(), {} |
46 return parent.rest_path(), {} |
47 return str(self.entity.e_schema).lower(), {} |
47 return str(self.entity.e_schema).lower(), {} |
48 |
48 |
49 @implements_adapter_compat('IEditControl') |
49 @implements_adapter_compat('IEditControl') |
50 def pre_web_edit(self): |
50 def pre_web_edit(self, form): |
51 """callback called by the web editcontroller when an entity will be |
51 """callback called by the web editcontroller when an entity will be |
52 created/modified, to let a chance to do some entity specific stuff. |
52 created/modified, to let a chance to do some entity specific stuff. |
53 |
53 |
54 Do nothing by default. |
54 Do nothing by default. |
55 """ |
55 """ |
171 """edit / create / copy an entity and return its eid""" |
171 """edit / create / copy an entity and return its eid""" |
172 etype = formparams['__type'] |
172 etype = formparams['__type'] |
173 entity = self._cw.vreg['etypes'].etype_class(etype)(self._cw) |
173 entity = self._cw.vreg['etypes'].etype_class(etype)(self._cw) |
174 entity.eid = valerror_eid(formparams['eid']) |
174 entity.eid = valerror_eid(formparams['eid']) |
175 is_main_entity = self._cw.form.get('__maineid') == formparams['eid'] |
175 is_main_entity = self._cw.form.get('__maineid') == formparams['eid'] |
|
176 if is_main_entity: |
|
177 formid = self._cw.form.get('__form_id', 'edition') |
|
178 else: |
|
179 # XXX inlined forms formid should be saved in a different formparams entry |
|
180 # inbetween, use cubicweb standard formid for inlined forms |
|
181 formid = 'edition' |
|
182 form = self._cw.vreg['forms'].select(formid, self._cw, entity=entity) |
176 # let a chance to do some entity specific stuff |
183 # let a chance to do some entity specific stuff |
177 entity.cw_adapt_to('IEditControl').pre_web_edit() |
184 entity.cw_adapt_to('IEditControl').pre_web_edit(form) |
178 # create a rql query from parameters |
185 # create a rql query from parameters |
179 rqlquery = RqlQuery() |
186 rqlquery = RqlQuery() |
180 # process inlined relations at the same time as attributes |
187 # process inlined relations at the same time as attributes |
181 # this will generate less rql queries and might be useful in |
188 # this will generate less rql queries and might be useful in |
182 # a few dark corners |
189 # a few dark corners |
183 if is_main_entity: |
|
184 formid = self._cw.form.get('__form_id', 'edition') |
|
185 else: |
|
186 # XXX inlined forms formid should be saved in a different formparams entry |
|
187 # inbetween, use cubicweb standard formid for inlined forms |
|
188 formid = 'edition' |
|
189 form = self._cw.vreg['forms'].select(formid, self._cw, entity=entity) |
|
190 eid = form.actual_eid(entity.eid) |
190 eid = form.actual_eid(entity.eid) |
191 try: |
191 try: |
192 editedfields = formparams['_cw_entity_fields'] |
192 editedfields = formparams['_cw_entity_fields'] |
193 except KeyError: |
193 except KeyError: |
194 try: |
194 try: |