comparison src/tools/xml_tools.py @ 863:97ee7594c788

core (xmlui): fixed types with empty value are now correctly managed in _dataFormField2XMLUIData
author Goffi <goffi@goffi.org>
date Tue, 25 Feb 2014 02:22:17 +0100
parents 462f2052af26
children 3ee2ec7ec010
comparison
equal deleted inserted replaced
862:ca7a2bf4fb40 863:97ee7594c788
32 32
33 # Helper functions 33 # Helper functions
34 34
35 def _dataFormField2XMLUIData(field): 35 def _dataFormField2XMLUIData(field):
36 """ Get data needed to create an XMLUI's Widget from Wokkel's data_form's Field 36 """ Get data needed to create an XMLUI's Widget from Wokkel's data_form's Field
37 field can be modified (if it's fixed and it has no value)
37 @param field: data_form.Field (it uses field.value, field.fieldType, field.label and field.var) 38 @param field: data_form.Field (it uses field.value, field.fieldType, field.label and field.var)
38 @return: widget_type, widget_args, widget_kwargs 39 @return: widget_type, widget_args, widget_kwargs
39 40
40 """ 41 """
41 widget_args = [field.value] 42 widget_args = [field.value]
42 widget_kwargs = {} 43 widget_kwargs = {}
43 if field.fieldType == 'fixed' or field.fieldType is None: 44 if field.fieldType == 'fixed' or field.fieldType is None:
44 widget_type = 'text' 45 widget_type = 'text'
46 if field.value is None:
47 if field.label is None:
48 warning(_("Fixed field has neither value nor label, ignoring it"))
49 field.value = ""
50 else:
51 field.value = field.label
52 field.label = None
53 widget_args[0] = field.value
45 elif field.fieldType == 'text-single': 54 elif field.fieldType == 'text-single':
46 widget_type = "string" 55 widget_type = "string"
47 elif field.fieldType == 'text-private': 56 elif field.fieldType == 'text-private':
48 widget_type = "password" 57 widget_type = "password"
49 elif field.fieldType == 'boolean': 58 elif field.fieldType == 'boolean':