From 93d4b44cff26f94c601a2981b3198dbca9bc64cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Fri, 31 Aug 2018 10:47:48 +0200 Subject: [PATCH] forms: don't add empty in checkboxes widget (#25988) --- wcs/qommon/form.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/wcs/qommon/form.py b/wcs/qommon/form.py index b64cbaa44..a9fb6579e 100644 --- a/wcs/qommon/form.py +++ b/wcs/qommon/form.py @@ -223,15 +223,18 @@ class RadiobuttonsWidget(quixote.form.RadiobuttonsWidget): r += htmltext(self.delim) return r.getvalue() -def checkbox_render_content(self): +def checkbox_render_content(self, empty_span=True): attrs = {'id': 'form_' + self.name} if self.required: attrs['aria-required'] = 'true' if self.attrs: attrs.update(self.attrs) - return htmltag("input", xml_end=True, type="checkbox", name=self.name, - value="yes", checked=self.value and "checked" or None, - **attrs) + htmltext('') # for custom style + checkbox = htmltag("input", xml_end=True, type="checkbox", name=self.name, + value="yes", checked=self.value and "checked" or None, + **attrs) + if empty_span: + return checkbox + htmltext('') # for custom style + return checkbox CheckboxWidget.render_content = checkbox_render_content @@ -1117,7 +1120,7 @@ class CheckboxesWidget(CompositeWidget): if widget.value: r += htmltext('') % widget.name widget.name = widget.name + 'xx' - r += widget.render_content() + r += widget.render_content(empty_span=False) r += htmltext('%s') % widget.title r += htmltext('') r += htmltext('') -- 2.18.0