Changeset 7693
- Timestamp:
- 06/18/08 11:33:04 (4 months ago)
- Files:
-
- django/trunk/AUTHORS (modified) (1 diff)
- django/trunk/django/newforms/widgets.py (modified) (2 diffs)
- django/trunk/tests/regressiontests/forms/forms.py (modified) (3 diffs)
- django/trunk/tests/regressiontests/forms/regressions.py (modified) (2 diffs)
- django/trunk/tests/regressiontests/forms/widgets.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/AUTHORS
r7692 r7693 66 66 Jiri Barton 67 67 Ned Batchelder <http://www.nedbatchelder.com/> 68 batiste@dosimple.ch 68 69 Shannon -jj Behrens <http://jjinux.blogspot.com/> 69 70 Esdras Beleza <linux@esdrasbeleza.com> django/trunk/django/newforms/widgets.py
r7083 r7693 282 282 283 283 def __unicode__(self): 284 return mark_safe(u'<label>%s %s</label>' % (self.tag(), 285 conditional_escape(force_unicode(self.choice_label)))) 284 if 'id' in self.attrs: 285 label_for = ' for="%s_%s"' % (self.attrs['id'], self.index) 286 else: 287 label_for = '' 288 choice_label = conditional_escape(force_unicode(self.choice_label)) 289 return mark_safe(u'<label%s>%s %s</label>' % (label_for, self.tag(), choice_label)) 286 290 287 291 def is_checked(self): … … 365 369 if has_id: 366 370 final_attrs = dict(final_attrs, id='%s_%s' % (attrs['id'], i)) 371 label_for = u' for="%s"' % final_attrs['id'] 372 else: 373 label_for = '' 374 367 375 cb = CheckboxInput(final_attrs, check_test=lambda value: value in str_values) 368 376 option_value = force_unicode(option_value) 369 377 rendered_cb = cb.render(name, option_value) 370 o utput.append(u'<li><label>%s %s</label></li>' % (rendered_cb,371 conditional_escape(force_unicode(option_label))))378 option_label = conditional_escape(force_unicode(option_label)) 379 output.append(u'<li><label%s>%s %s</label></li>' % (label_for, rendered_cb, option_label)) 372 380 output.append(u'</ul>') 373 381 return mark_safe(u'\n'.join(output)) django/trunk/tests/regressiontests/forms/forms.py
r7322 r7693 444 444 >>> print f['language'] 445 445 <ul> 446 <li><label ><input type="radio" id="id_language_0" value="P" name="language" /> Python</label></li>447 <li><label ><input type="radio" id="id_language_1" value="J" name="language" /> Java</label></li>446 <li><label for="id_language_0"><input type="radio" id="id_language_0" value="P" name="language" /> Python</label></li> 447 <li><label for="id_language_1"><input type="radio" id="id_language_1" value="J" name="language" /> Java</label></li> 448 448 </ul> 449 449 … … 454 454 <tr><th><label for="id_name">Name:</label></th><td><input type="text" name="name" id="id_name" /></td></tr> 455 455 <tr><th><label for="id_language_0">Language:</label></th><td><ul> 456 <li><label ><input type="radio" id="id_language_0" value="P" name="language" /> Python</label></li>457 <li><label ><input type="radio" id="id_language_1" value="J" name="language" /> Java</label></li>456 <li><label for="id_language_0"><input type="radio" id="id_language_0" value="P" name="language" /> Python</label></li> 457 <li><label for="id_language_1"><input type="radio" id="id_language_1" value="J" name="language" /> Java</label></li> 458 458 </ul></td></tr> 459 459 >>> print f.as_ul() 460 460 <li><label for="id_name">Name:</label> <input type="text" name="name" id="id_name" /></li> 461 461 <li><label for="id_language_0">Language:</label> <ul> 462 <li><label ><input type="radio" id="id_language_0" value="P" name="language" /> Python</label></li>463 <li><label ><input type="radio" id="id_language_1" value="J" name="language" /> Java</label></li>462 <li><label for="id_language_0"><input type="radio" id="id_language_0" value="P" name="language" /> Python</label></li> 463 <li><label for="id_language_1"><input type="radio" id="id_language_1" value="J" name="language" /> Java</label></li> 464 464 </ul></li> 465 465 >>> print f.as_p() 466 466 <p><label for="id_name">Name:</label> <input type="text" name="name" id="id_name" /></p> 467 467 <p><label for="id_language_0">Language:</label> <ul> 468 <li><label ><input type="radio" id="id_language_0" value="P" name="language" /> Python</label></li>469 <li><label ><input type="radio" id="id_language_1" value="J" name="language" /> Java</label></li>468 <li><label for="id_language_0"><input type="radio" id="id_language_0" value="P" name="language" /> Python</label></li> 469 <li><label for="id_language_1"><input type="radio" id="id_language_1" value="J" name="language" /> Java</label></li> 470 470 </ul></p> 471 471 … … 536 536 >>> print f['composers'] 537 537 <ul> 538 <li><label ><input type="checkbox" name="composers" value="J" id="composers_id_0" /> John Lennon</label></li>539 <li><label ><input type="checkbox" name="composers" value="P" id="composers_id_1" /> Paul McCartney</label></li>538 <li><label for="composers_id_0"><input type="checkbox" name="composers" value="J" id="composers_id_0" /> John Lennon</label></li> 539 <li><label for="composers_id_1"><input type="checkbox" name="composers" value="P" id="composers_id_1" /> Paul McCartney</label></li> 540 540 </ul> 541 541 django/trunk/tests/regressiontests/forms/regressions.py
r6619 r7693 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>\n<li><label for="id_somechoice_0"><input type="radio" id="id_somechoice_0" value="\xc5" name="somechoice" /> En tied\xe4</label></li>\n<li><label for="id_somechoice_1"><input type="radio" id="id_somechoice_1" value="\xf8" name="somechoice" /> Mies</label></li>\n<li><label for="id_somechoice_2"><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 … … 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>\n<li><label for="id_somechoice_0"><input type="radio" id="id_somechoice_0" value="\xc5" name="somechoice" /> En tied\xe4</label></li>\n<li><label for="id_somechoice_1"><input type="radio" id="id_somechoice_1" value="\xf8" name="somechoice" /> Mies</label></li>\n<li><label for="id_somechoice_2"><input type="radio" id="id_somechoice_2" value="\xdf" name="somechoice" /> Nainen</label></li>\n</ul></p>' 60 60 >>> deactivate() 61 61 django/trunk/tests/regressiontests/forms/widgets.py
r7646 r7693 742 742 >>> print w.render('beatle', 'J', choices=(('J', 'John'), ('P', 'Paul'), ('G', 'George'), ('R', 'Ringo'))) 743 743 <ul> 744 <li><label ><input checked="checked" type="radio" id="foo_0" value="J" name="beatle" /> John</label></li>745 <li><label ><input type="radio" id="foo_1" value="P" name="beatle" /> Paul</label></li>746 <li><label ><input type="radio" id="foo_2" value="G" name="beatle" /> George</label></li>747 <li><label ><input type="radio" id="foo_3" value="R" name="beatle" /> Ringo</label></li>744 <li><label for="foo_0"><input checked="checked" type="radio" id="foo_0" value="J" name="beatle" /> John</label></li> 745 <li><label for="foo_1"><input type="radio" id="foo_1" value="P" name="beatle" /> Paul</label></li> 746 <li><label for="foo_2"><input type="radio" id="foo_2" value="G" name="beatle" /> George</label></li> 747 <li><label for="foo_3"><input type="radio" id="foo_3" value="R" name="beatle" /> Ringo</label></li> 748 748 </ul> 749 749 … … 752 752 >>> print w.render('beatle', 'J', choices=(('J', 'John'), ('P', 'Paul'), ('G', 'George'), ('R', 'Ringo')), attrs={'id':'bar'}) 753 753 <ul> 754 <li><label ><input checked="checked" type="radio" id="bar_0" value="J" name="beatle" /> John</label></li>755 <li><label ><input type="radio" id="bar_1" value="P" name="beatle" /> Paul</label></li>756 <li><label ><input type="radio" id="bar_2" value="G" name="beatle" /> George</label></li>757 <li><label ><input type="radio" id="bar_3" value="R" name="beatle" /> Ringo</label></li>754 <li><label for="bar_0"><input checked="checked" type="radio" id="bar_0" value="J" name="beatle" /> John</label></li> 755 <li><label for="bar_1"><input type="radio" id="bar_1" value="P" name="beatle" /> Paul</label></li> 756 <li><label for="bar_2"><input type="radio" id="bar_2" value="G" name="beatle" /> George</label></li> 757 <li><label for="bar_3"><input type="radio" id="bar_3" value="R" name="beatle" /> Ringo</label></li> 758 758 </ul> 759 759
