Backend forms: Do not allow to click empty labels

This commit is contained in:
Raphael Michel
2020-10-09 12:19:44 +02:00
parent dca61447cf
commit da725c0bff
2 changed files with 9 additions and 0 deletions

View File

@@ -19,6 +19,12 @@ def render_label(content, label_for=None, label_class=None, label_title='', opti
attrs['class'] = label_class
if label_title:
attrs['title'] = label_title
if text_value(content) == ' ':
# Empty label, e.g. checkbox
attrs.setdefault('class', '')
attrs['class'] += ' label-empty'
builder = '<{tag}{attrs}>{content}{opt}</{tag}>'
return format_html(
builder,