[muledit] form may contains subforms with nothing editable that will be s kipped, so ensure we choose one with something to display when rendering table headers stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 29 Sep 2010 12:13:44 +0200
branchstable
changeset 6357 2d277c67f103
parent 6356 e89f71a41e20
child 6358 22c95c5ef12d
[muledit] form may contains subforms with nothing editable that will be s kipped, so ensure we choose one with something to display when rendering table headers
web/views/formrenderers.py
--- a/web/views/formrenderers.py	Wed Sep 29 09:01:57 2010 +0200
+++ b/web/views/formrenderers.py	Wed Sep 29 12:13:44 2010 +0200
@@ -335,8 +335,14 @@
     def render_fields(self, w, form, values):
         if form.parent_form is None:
             w(u'<table class="listing">')
-            subfields = [field for field in form.forms[0].fields
-                         if field.is_visible()]
+            # get fields from the first subform with something to display (we
+            # may have subforms with nothing editable that will simply be
+            # skipped later)
+            for subform in form.forms:
+                subfields = [field for field in subform.fields
+                             if field.is_visible()]
+                if subfields:
+                    break
             if subfields:
                 # main form, display table headers
                 w(u'<tr class="header">')