Use simple field labels when possible
only use template if it must include icons etc.
This commit is contained in:
parent
2a22e8939c
commit
8b3a9c9dad
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue