--- a/web/test/unittest_form.py Mon Jun 29 18:41:07 2009 +0200
+++ b/web/test/unittest_form.py Mon Jun 29 18:42:37 2009 +0200
@@ -5,6 +5,7 @@
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
"""
+from __future__ import with_statement
from xml.etree.ElementTree import fromstring
@@ -98,6 +99,14 @@
inputs = pageinfo.find_tag('input', False)
self.failIf(any(attrs for t, attrs in inputs if attrs.get('name') == '__linkto'))
+ def test_reledit_composite_field(self):
+ rset = self.execute('INSERT BlogEntry X: X title "cubicweb.org", X content "hop"')
+ form = self.vreg.select_object('views', 'reledit', self.request(),
+ rset=rset, row=0, rtype='content')
+ data = form.render(row=0, rtype='content')
+ self.failUnless('edits-content' in data)
+ self.failUnless('edits-content_format' in data)
+
# form view tests #########################################################
def test_massmailing_formview(self):
--- a/web/views/formrenderers.py Mon Jun 29 18:41:07 2009 +0200
+++ b/web/views/formrenderers.py Mon Jun 29 18:42:37 2009 +0200
@@ -215,12 +215,29 @@
class BaseFormRenderer(FormRenderer):
- """use form_renderer_id = 'base' if you want base FormRenderer without
- adaptation by selection
+ """use form_renderer_id = 'base' if you want base FormRenderer layout even
+ when selected for an entity
"""
id = 'base'
+class EntityBaseFormRenderer(BaseFormRenderer):
+ """use form_renderer_id = 'base' if you want base FormRenderer layout even
+ when selected for an entity
+ """
+ __select__ = entity_implements('Any')
+
+ def display_field(self, form, field):
+ if not super(EntityBaseFormRenderer, self).display_field(form, field):
+ if isinstance(field, HiddenInitialValueField):
+ field = field.visible_field
+ ismeta = form.edited_entity.e_schema.is_metadata(field.name)
+ return ismeta is not None and (
+ ismeta[0] in self.display_fields or
+ (ismeta[0], 'subject') in self.display_fields)
+ return True
+
+
class HTableFormRenderer(FormRenderer):
"""display fields horizontally in a table
@@ -310,9 +327,11 @@
w(u'</tr>')
-class EntityFormRenderer(FormRenderer):
+class EntityFormRenderer(EntityBaseFormRenderer):
"""specific renderer for entity edition form (edition)"""
- __select__ = entity_implements('Any') & yes()
+ id = 'default'
+ # needs some additional points in some case (XXX explain cases)
+ __select__ = EntityBaseFormRenderer.__select__ & yes()
_options = FormRenderer._options + ('display_relations_form',)
display_relations_form = True