Fixed #19581 -- ensure unique html ids with CheckboxSelectMultiple widgets

ID check is now done the same way as MultipleHiddenInput.
This commit is contained in:
Loic Raucy 2013-01-09 10:07:44 +01:00 committed by Preston Holmes
parent 227bd3f8db
commit 62f842e2e5
2 changed files with 11 additions and 4 deletions

View file

@ -861,6 +861,13 @@ beatle J R Ringo False""")
<li><label for="abc_0"><input checked="checked" type="checkbox" name="letters" value="a" id="abc_0" /> A</label></li>
<li><label for="abc_1"><input type="checkbox" name="letters" value="b" id="abc_1" /> B</label></li>
<li><label for="abc_2"><input checked="checked" type="checkbox" name="letters" value="c" id="abc_2" /> C</label></li>
</ul>""")
# Each input gets a separate ID when the ID is passed to the constructor
self.assertHTMLEqual(CheckboxSelectMultiple(attrs={'id': 'abc'}).render('letters', list('ac'), choices=zip(list('abc'), list('ABC'))), """<ul>
<li><label for="abc_0"><input checked="checked" type="checkbox" name="letters" value="a" id="abc_0" /> A</label></li>
<li><label for="abc_1"><input type="checkbox" name="letters" value="b" id="abc_1" /> B</label></li>
<li><label for="abc_2"><input checked="checked" type="checkbox" name="letters" value="c" id="abc_2" /> C</label></li>
</ul>""")
def test_multi(self):