Ticket #5731: 4080-rebase6783.diff
File 4080-rebase6783.diff, 6.4 KB (added by , 17 years ago) |
---|
-
django/newforms/widgets.py
419 419 420 420 def render(self): 421 421 """Outputs a <ul> for this set of radio fields.""" 422 return mark_safe(u'<ul>\n%s\n</ul>' % u'\n'.join([u'<li>%s</li>' 423 % force_unicode(w) for w in self])) 422 return mark_safe(u'<ul%s>\n%s\n</ul>' % 423 (flatatt(self.attrs), 424 u'\n'.join([u'<li>%s</li>' % force_unicode(w) for w in self]))) 424 425 425 426 class RadioSelect(Select): 426 427 renderer = RadioFieldRenderer -
tests/regressiontests/forms/regressions.py
40 40 ... somechoice = ChoiceField(choices=GENDERS, widget=RadioSelect(), label=u'\xc5\xf8\xdf') 41 41 >>> f = SomeForm() 42 42 >>> f.as_p() 43 u'<p><label for="id_somechoice_0">\xc5\xf8\xdf:</label> <ul >\n<li><label><input type="radio" id="id_somechoice_0" value="\xc5" name="somechoice" /> En tied\xe4</label></li>\n<li><label><input type="radio" id="id_somechoice_1" value="\xf8" name="somechoice" /> Mies</label></li>\n<li><label><input type="radio" id="id_somechoice_2" value="\xdf" name="somechoice" /> Nainen</label></li>\n</ul></p>'43 u'<p><label for="id_somechoice_0">\xc5\xf8\xdf:</label> <ul id="id_somechoice">\n<li><label><input type="radio" id="id_somechoice_0" value="\xc5" name="somechoice" /> En tied\xe4</label></li>\n<li><label><input type="radio" id="id_somechoice_1" value="\xf8" name="somechoice" /> Mies</label></li>\n<li><label><input type="radio" id="id_somechoice_2" value="\xdf" name="somechoice" /> Nainen</label></li>\n</ul></p>' 44 44 45 45 Testing choice validation with UTF-8 bytestrings as input (these are the 46 46 Russian abbreviations "мес." and "шт.". … … 56 56 >>> activate('ru') 57 57 >>> f = SomeForm({}) 58 58 >>> f.as_p() 59 u'<ul class="errorlist"><li>\u041e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u043b\u0435.</li></ul>\n<p><label for="id_somechoice_0">\xc5\xf8\xdf:</label> <ul >\n<li><label><input type="radio" id="id_somechoice_0" value="\xc5" name="somechoice" /> En tied\xe4</label></li>\n<li><label><input type="radio" id="id_somechoice_1" value="\xf8" name="somechoice" /> Mies</label></li>\n<li><label><input type="radio" id="id_somechoice_2" value="\xdf" name="somechoice" /> Nainen</label></li>\n</ul></p>'59 u'<ul class="errorlist"><li>\u041e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u043b\u0435.</li></ul>\n<p><label for="id_somechoice_0">\xc5\xf8\xdf:</label> <ul id="id_somechoice">\n<li><label><input type="radio" id="id_somechoice_0" value="\xc5" name="somechoice" /> En tied\xe4</label></li>\n<li><label><input type="radio" id="id_somechoice_1" value="\xf8" name="somechoice" /> Mies</label></li>\n<li><label><input type="radio" id="id_somechoice_2" value="\xdf" name="somechoice" /> Nainen</label></li>\n</ul></p>' 60 60 >>> deactivate() 61 61 62 62 Deep copying translated text shouldn't raise an error -
tests/regressiontests/forms/forms.py
423 423 zero-based index. 424 424 >>> f = FrameworkForm(auto_id='id_%s') 425 425 >>> print f['language'] 426 <ul >426 <ul id="id_language"> 427 427 <li><label><input type="radio" id="id_language_0" value="P" name="language" /> Python</label></li> 428 428 <li><label><input type="radio" id="id_language_1" value="J" name="language" /> Java</label></li> 429 429 </ul> … … 433 433 ID of the *first* radio button. 434 434 >>> print f 435 435 <tr><th><label for="id_name">Name:</label></th><td><input type="text" name="name" id="id_name" /></td></tr> 436 <tr><th><label for="id_language_0">Language:</label></th><td><ul >436 <tr><th><label for="id_language_0">Language:</label></th><td><ul id="id_language"> 437 437 <li><label><input type="radio" id="id_language_0" value="P" name="language" /> Python</label></li> 438 438 <li><label><input type="radio" id="id_language_1" value="J" name="language" /> Java</label></li> 439 439 </ul></td></tr> 440 440 >>> print f.as_ul() 441 441 <li><label for="id_name">Name:</label> <input type="text" name="name" id="id_name" /></li> 442 <li><label for="id_language_0">Language:</label> <ul >442 <li><label for="id_language_0">Language:</label> <ul id="id_language"> 443 443 <li><label><input type="radio" id="id_language_0" value="P" name="language" /> Python</label></li> 444 444 <li><label><input type="radio" id="id_language_1" value="J" name="language" /> Java</label></li> 445 445 </ul></li> 446 446 >>> print f.as_p() 447 447 <p><label for="id_name">Name:</label> <input type="text" name="name" id="id_name" /></p> 448 <p><label for="id_language_0">Language:</label> <ul >448 <p><label for="id_language_0">Language:</label> <ul id="id_language"> 449 449 <li><label><input type="radio" id="id_language_0" value="P" name="language" /> Python</label></li> 450 450 <li><label><input type="radio" id="id_language_1" value="J" name="language" /> Java</label></li> 451 451 </ul></p> -
tests/regressiontests/forms/widgets.py
740 740 # Attributes provided at instantiation are passed to the constituent inputs 741 741 >>> w = RadioSelect(attrs={'id':'foo'}) 742 742 >>> print w.render('beatle', 'J', choices=(('J', 'John'), ('P', 'Paul'), ('G', 'George'), ('R', 'Ringo'))) 743 <ul >743 <ul id="foo"> 744 744 <li><label><input checked="checked" type="radio" id="foo_0" value="J" name="beatle" /> John</label></li> 745 745 <li><label><input type="radio" id="foo_1" value="P" name="beatle" /> Paul</label></li> 746 746 <li><label><input type="radio" id="foo_2" value="G" name="beatle" /> George</label></li> … … 750 750 # Attributes provided at render-time are passed to the constituent inputs 751 751 >>> w = RadioSelect() 752 752 >>> print w.render('beatle', 'J', choices=(('J', 'John'), ('P', 'Paul'), ('G', 'George'), ('R', 'Ringo')), attrs={'id':'bar'}) 753 <ul >753 <ul id="bar"> 754 754 <li><label><input checked="checked" type="radio" id="bar_0" value="J" name="beatle" /> John</label></li> 755 755 <li><label><input type="radio" id="bar_1" value="P" name="beatle" /> Paul</label></li> 756 756 <li><label><input type="radio" id="bar_2" value="G" name="beatle" /> George</label></li>