Skip to content

Commit 1b00d5f

Browse files
paulchubatyydyve
authored andcommitted
Add test for the use case
1 parent 030cee9 commit 1b00d5f

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/test_bootstrap_field_radio_select.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ class DisabledSelectTestForm(forms.Form):
2222
widget=forms.RadioSelect,
2323
disabled=True,
2424
)
25+
26+
27+
class SelectOtherTestForm(forms.Form):
28+
test = forms.ChoiceField(
29+
choices=(
30+
(1, "one"),
31+
(2, "two"),
32+
),
33+
widget=forms.RadioSelect(attrs={"form": "another-form"})
2534

2635

2736
class BootstrapFieldSelectTestCase(BootstrapTestCase):
@@ -111,3 +120,25 @@ def test_disabled_select(self):
111120
"</div>"
112121
),
113122
)
123+
124+
def test_other_form_select(self):
125+
"""Test field with select that belongs to another form widget."""
126+
self.maxDiff = None
127+
self.assertHTMLEqual(
128+
self.render("{% bootstrap_field form.test %}", context={"form": DisabledSelectTestForm()}),
129+
(
130+
'<div class="django_bootstrap5-req mb-3">'
131+
'<label class="form-label">Test</label>'
132+
'<div class="" disabled required id="id_test">'
133+
'<div class="form-check">'
134+
'<input class="form-check-input" form="another-form" type="radio" name="test" id="id_test_0" value="1">'
135+
'<label class="form-check-label" for="id_test_0">one</label>'
136+
"</div>"
137+
'<div class="form-check">'
138+
'<input class="form-check-input" form="another-form" type="radio" name="test" id="id_test_1" value="2">'
139+
'<label class="form-check-label" for="id_test_1">two</label>'
140+
"</div>"
141+
"</div>"
142+
"</div>"
143+
),
144+
)

0 commit comments

Comments
 (0)