Use simple field labels when possible

only use template if it must include icons etc.
This commit is contained in:
Lance Edgar 2024-04-25 22:49:37 -05:00
parent 2a22e8939c
commit 8b3a9c9dad

View file

@ -1093,15 +1093,23 @@ class Form(object):
label_contents.append(HTML.literal('   ')) label_contents.append(HTML.literal('   '))
label_contents.append(icon) label_contents.append(icon)
# nb. must apply hack to get <template #label> as final result # only declare label template if it's complex
label_template = HTML.tag('template', c=label_contents, html = [html]
**{'#label': 1}) if len(label_contents) > 1:
label_template = label_template.replace(
HTML.literal('<template #label="1"'), # nb. must apply hack to get <template #label> as final result
HTML.literal('<template #label')) label_template = HTML.tag('template', c=label_contents,
**{'#label': 1})
label_template = label_template.replace(
HTML.literal('<template #label="1"'),
HTML.literal('<template #label'))
html.insert(0, label_template)
else: # simple label
attrs['label'] = label
# and finally wrap it all in a <b-field> # and finally wrap it all in a <b-field>
return HTML.tag('b-field', c=[label_template, html], **attrs) return HTML.tag('b-field', c=html, **attrs)
elif field: # hidden field elif field: # hidden field