comparison tools/xml_tools.py @ 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 7c00c4b0a5c2
children 9ee4a1d0d7fb
comparison
equal deleted inserted replaced
159:2fa58703f1b7 160:f494cba56a9e
33 form_ui = XMLUI("form", "vertical") 33 form_ui = XMLUI("form", "vertical")
34 34
35 if form.instructions: 35 if form.instructions:
36 form_ui.addText('\n'.join(form.instructions), 'instructions') 36 form_ui.addText('\n'.join(form.instructions), 'instructions')
37 37
38 form_ui.changeLayout("pairs") 38 labels = filter(lambda field:field.label,form.fieldList)
39 if labels:
40 #if there is no label, we don't need to use pairs
41 form_ui.changeLayout("pairs")
39 42
40 for field in form.fieldList: 43 for field in form.fieldList:
41 if field.fieldType == 'fixed': 44 if field.fieldType == 'fixed':
42 __field_type = 'text' 45 __field_type = 'text'
43 elif field.fieldType == 'text-single': 46 elif field.fieldType == 'text-single':
48 __field_type = "list" 51 __field_type = "list"
49 else: 52 else:
50 error (u"FIXME FIXME FIXME: Type [%s] is not managed yet by SàT" % field.fieldType) 53 error (u"FIXME FIXME FIXME: Type [%s] is not managed yet by SàT" % field.fieldType)
51 __field_type = "string" 54 __field_type = "string"
52 55
53 if field.label: 56 if labels:
54 form_ui.addLabel(field.label) 57 if field.label:
55 else: 58 form_ui.addLabel(field.label)
56 form_ui.addEmpty() 59 else:
60 form_ui.addEmpty()
57 61
58 elem = form_ui.addElement(__field_type, field.var, field.value, [option.value for option in field.options]) 62 elem = form_ui.addElement(__field_type, field.var, field.value, [option.value for option in field.options])
59 return form_ui.toXml() 63 return form_ui.toXml()
60 64
61 def tupleList2dataForm(values): 65 def tupleList2dataForm(values):