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(icon)
|
||||
|
||||
# only declare label template if it's complex
|
||||
html = [html]
|
||||
if len(label_contents) > 1:
|
||||
|
||||
# nb. must apply hack to get <template #label> as final result
|
||||
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>
|
||||
return HTML.tag('b-field', c=[label_template, html], **attrs)
|
||||
return HTML.tag('b-field', c=html, **attrs)
|
||||
|
||||
elif field: # hidden field
|
||||
|
||||
|
|
Loading…
Reference in a new issue