Projet

Général

Profil

0001-forms-put-standalone-checkboxes-in-a-label-tag-26002.patch

Frédéric Péters, 31 août 2018 17:39

Télécharger (1,86 ko)

Voir les différences:

Subject: [PATCH] forms: put standalone checkboxes in a <label> tag (#26002)

 wcs/qommon/form.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
wcs/qommon/form.py
223 223
                r += htmltext(self.delim)
224 224
        return r.getvalue()
225 225

  
226
def checkbox_render_content(self, empty_span=True):
226
def checkbox_render_content(self, standalone=True):
227 227
    attrs = {'id': 'form_' + self.name}
228 228
    if self.required:
229 229
        attrs['aria-required'] = 'true'
......
232 232
    checkbox = htmltag("input", xml_end=True, type="checkbox", name=self.name,
233 233
                       value="yes", checked=self.value and "checked" or None,
234 234
                       **attrs)
235
    if empty_span:
236
        return checkbox + htmltext('<span></span>')  # for custom style
235
    if standalone:
236
        return htmltext('<label>%s<span></span></label>' % checkbox)  # for custom style
237 237
    return checkbox
238 238
CheckboxWidget.render_content = checkbox_render_content
239 239

  
......
1120 1120
                if widget.value:
1121 1121
                    r += htmltext('<input type="hidden" name="%s" value="yes" >') % widget.name
1122 1122
                widget.name = widget.name + 'xx'
1123
            r += widget.render_content(empty_span=False)
1123
            r += widget.render_content(standalone=False)
1124 1124
            r += htmltext('<span>%s</span>') % widget.title
1125 1125
            r += htmltext('</label>')
1126 1126
            r += htmltext('</li>')
1127
-