Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#29200 closed Bug (fixed)

RadioSelect does not render its label in MultiWidget

Reported by: Takayuki Hirai Owned by: Tim Graham
Component: Forms Version: 1.11
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The code:

from django import forms


class MyWidget(forms.MultiWidget):
    def __init__(self):
        widgets = [
            forms.RadioSelect(
                choices=[('aaa', 'bbb')]
            )
        ]
        super(MyWidget, self).__init__(
            widgets=widgets,
            attrs={},
        )

    def decompress(self, v):
        return []


print(MyWidget().render('wname', None))

Actual output:

<ul>
    <li><input type="radio" name="wname_0" value="aaa" />


</li>
</ul>

Expected output:

<ul>
    <li><label><input type="radio" name="wname_0" value="aaa" />
 bbb</label>

</li>
</ul>

It seems that this problem is caused by the following reasons:

  • a template of RadioSelect requires wrap_label context varialbe to render LABEL elements
  • MultiWidget.get_context() drops wrap_label

Change History (8)

comment:1 by Takayuki Hirai, 6 years ago

Type: UncategorizedBug

comment:2 by Tim Graham, 6 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Tim Graham, 6 years ago

Owner: changed from nobody to Tim Graham
Status: newassigned

comment:4 by Tim Graham, 6 years ago

Has patch: set

comment:5 by Carlton Gibson, 6 years ago

Triage Stage: AcceptedReady for checkin

comment:6 by Tim Graham <timograham@…>, 6 years ago

Resolution: fixed
Status: assignedclosed

In 87dc0844:

Fixed #29200 -- Fixed label rendering when using RadioSelect and CheckboxSelectMultiple with MultiWidget.

comment:7 by karyon, 6 years ago

there's no backport to 2.0.x, is that intended?

comment:8 by Tim Graham, 6 years ago

Yes, it doesn't qualify for a backport based on the supported versions policy

Note: See TracTickets for help on using tickets.
Back to Top