# HG changeset patch # User Goffi # Date 1638974757 -3600 # Node ID d33da3fe34a54e6b79a40786b76615158043138f # Parent b9718216a1c0b5f2149dab3f232711eb4347ddda tools (xml_tools): implement `list-multi` in `_dataFormField2XMLUIData`: `list-multi` was missing and thus these data form field type was not supported, resulting in those fields shown as a text field. Due to legacy, current implementation use a hack to split values, this should be fixed later by using proper serialisation. diff -r b9718216a1c0 -r d33da3fe34a5 sat/tools/xml_tools.py --- a/sat/tools/xml_tools.py Wed Dec 01 16:13:31 2021 +0100 +++ b/sat/tools/xml_tools.py Wed Dec 08 15:45:57 2021 +0100 @@ -60,7 +60,7 @@ @param read_only (bool): if True and it makes sense, create a read only input widget @return: a tuple (widget_type, widget_args, widget_kwargs) """ - widget_args = [field.value] + widget_args = field.values or [None] widget_kwargs = {} if field.fieldType is None and field.ext_type is not None: # we have an extended field @@ -76,6 +76,7 @@ widget_args[0] = element.toXml() widget_kwargs["read_only"] = read_only else: + raise exceptions.DataError("unknown extended type {ext_type}".format( ext_type = field.ext_type)) @@ -119,6 +120,14 @@ ] widget_kwargs["selected"] = widget_args widget_args = [] + elif field.fieldType == "list-multi": + widget_type = "list" + widget_kwargs["options"] = [ + (option.value, option.label or option.value) for option in field.options + ] + widget_kwargs["selected"] = widget_args + widget_kwargs["styles"] = ["multi"] + widget_args = [] else: log.error( "FIXME FIXME FIXME: Type [%s] is not managed yet by SàT" % field.fieldType @@ -426,9 +435,14 @@ for key, value in xmlui_data.items(): if not key.startswith(SAT_FORM_PREFIX): continue - if isinstance(value, str) and '\n' in value: - # data form expects multi-lines text to be in separated values - value = value.split('\n') + if isinstance(value, str): + if "\n" in value: + # data form expects multi-lines text to be in separated values + value = value.split('\n') + elif "\t" in value: + # FIXME: workaround to handle multiple values. Proper serialisation must + # be done in XMLUI + value = value.split("\t") ret[key[len(SAT_FORM_PREFIX) :]] = _cleanValue(value) return ret