comparison sat/tools/xml_tools.py @ 3903:384b7e6c2dbf

tools (xml_tools): handle `required` field in `dataDict2dataForm`: rel 372
author Goffi <goffi@goffi.org>
date Wed, 21 Sep 2022 22:43:55 +0200
parents 0fac164ff2d8
children 4cb38c8312a1
comparison
equal deleted inserted replaced
3902:32b38dd3ac18 3903:384b7e6c2dbf
257 - "name" is used to set the "var" attribute of data_form.Field 257 - "name" is used to set the "var" attribute of data_form.Field
258 - "label", and "value" follow same attribude in data_form.Field 258 - "label", and "value" follow same attribude in data_form.Field
259 - "xhtml" is used for "xml" fields with child in the C.NS_XHTML namespace 259 - "xhtml" is used for "xml" fields with child in the C.NS_XHTML namespace
260 - "options" are list of dict with optional "label" and mandatory "value" 260 - "options" are list of dict with optional "label" and mandatory "value"
261 following suitable attributes from data_form.Option 261 following suitable attributes from data_form.Option
262 - "required" is the same as data_form.Field.required
262 """ 263 """
263 # TODO: describe format 264 # TODO: describe format
264 fields = [] 265 fields = []
265 for field_data in data_dict["fields"]: 266 for field_data in data_dict["fields"]:
266 field_type = field_data.get('type', 'text-single') 267 field_type = field_data.get('type', 'text-single')
267 kwargs = { 268 kwargs = {
268 "fieldType": field_type, 269 "fieldType": field_type,
269 "var": field_data["name"], 270 "var": field_data["name"],
270 "label": field_data.get('label'), 271 "label": field_data.get('label'),
271 "value": field_data.get("value"), 272 "value": field_data.get("value"),
273 "required": field_data.get("required")
272 } 274 }
273 if field_type == "xhtml": 275 if field_type == "xhtml":
274 kwargs.update({ 276 kwargs.update({
275 "fieldType": None, 277 "fieldType": None,
276 "ext_type": "xml", 278 "ext_type": "xml",