web/views/formrenderers.py
changeset 2574 37154aa90947
parent 2561 c6f0634e2d77
child 2575 e033939d5664
--- a/web/views/formrenderers.py	Thu Jul 30 18:49:24 2009 +0200
+++ b/web/views/formrenderers.py	Thu Jul 30 18:50:41 2009 +0200
@@ -193,7 +193,16 @@
         byfieldset = {}
         for field in fields:
             byfieldset.setdefault(field.fieldset, []).append(field)
-        for fieldset, fields in byfieldset.iteritems():
+        if form.fieldsets_in_order:
+            fieldsets = form.fieldsets_in_order
+        else:
+            fieldsets = byfieldset.keys()
+        for fieldset in fieldsets:
+            try:
+                fields = byfieldset.pop(fieldset)
+            except KeyError:
+                self.warning('no such fieldset: %s (%s)', fieldset, form)
+                continue
             w(u'<fieldset class="%s">' % (fieldset or u'default'))
             if fieldset:
                 w(u'<legend>%s</legend>' % self.req._(fieldset))
@@ -213,6 +222,8 @@
                     w(self.render_help(form, field))
                 w(u'</td></tr>')
             w(u'</table></fieldset>')
+        if byfieldset:
+            self.warning('unused fieldsets: %s', ', '.join(byfieldset))
 
     def render_buttons(self, w, form):
         if not form.form_buttons: