changeset 160:f494cba56a9e

xml tools: pairs layout is not used anymore if there is no label in dataForm2xml
author Goffi <goffi@goffi.org>
date Fri, 06 Aug 2010 12:10:43 +0800
parents 2fa58703f1b7
children c37826d80f2a
files tools/xml_tools.py
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/tools/xml_tools.py	Wed Aug 04 17:57:51 2010 +0800
+++ b/tools/xml_tools.py	Fri Aug 06 12:10:43 2010 +0800
@@ -35,7 +35,10 @@
     if form.instructions:
         form_ui.addText('\n'.join(form.instructions), 'instructions')
     
-    form_ui.changeLayout("pairs")
+    labels = filter(lambda field:field.label,form.fieldList)
+    if labels:
+        #if there is no label, we don't need to use pairs
+        form_ui.changeLayout("pairs")
     
     for field in form.fieldList:
         if field.fieldType == 'fixed':
@@ -50,10 +53,11 @@
             error (u"FIXME FIXME FIXME: Type [%s] is not managed yet by SàT" % field.fieldType)
             __field_type = "string"
         
-        if field.label:
-            form_ui.addLabel(field.label)
-        else:
-            form_ui.addEmpty()
+        if labels:
+            if field.label:
+                form_ui.addLabel(field.label)
+            else:
+                form_ui.addEmpty()
 
         elem = form_ui.addElement(__field_type, field.var, field.value, [option.value for option in field.options]) 
     return form_ui.toXml()