Backport change for cubicweb #15755515
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 12 Oct 2016 10:57:57 +0200
changeset 1737 8d1f91ac86d1
parent 1736 e6c7685a6b3b
child 1738 508d1fb489a7
Backport change for cubicweb #15755515
views/patches.py
--- a/views/patches.py	Wed Oct 12 10:57:05 2016 +0200
+++ b/views/patches.py	Wed Oct 12 10:57:57 2016 +0200
@@ -74,3 +74,31 @@
         if field is None:
             raise
         return field
+
+
+# allow configuration of inlined form renderer using a class attribute #############################
+# (https://www.cubicweb.org/ticket/15755515)
+
+from logilab.common.decorators import cached  # noqa
+from cubicweb.web.views import autoform  # noqa
+
+autoform.InlineEntityEditionFormView.form_renderer_id = 'inline'
+
+
+@monkeypatch(autoform.InlineEntityEditionFormView, methodname='form')
+@property
+@cached
+def form(self):
+    entity = self._entity()
+    form = self._cw.vreg['forms'].select('edition', self._cw,
+                                         entity=entity,
+                                         formtype='inlined',
+                                         form_renderer_id=self.form_renderer_id,
+                                         copy_nav_params=False,
+                                         mainform=False,
+                                         parent_form=self.pform,
+                                         **self.cw_extra_kwargs)
+    if self.pform is None:
+        form.restore_previous_post(form.session_key())
+    self.add_hiddens(form, entity)
+    return form