Ticket #5731: 4080.diff

File 4080.diff, 6.3 KB (added by Karen Tracey <kmtracey@…>, 17 years ago)
  • django/newforms/widgets.py

     
    383383
    384384    def render(self):
    385385        """Outputs a <ul> for this set of radio fields."""
    386         return u'<ul>\n%s\n</ul>' % u'\n'.join([u'<li>%s</li>' % force_unicode(w) for w in self])
     386        return u'<ul%s>\n%s\n</ul>' % (flatatt(self.attrs), u'\n'.join([u'<li>%s</li>' % force_unicode(w) for w in self]))
    387387
    388388class RadioSelect(Select):
    389389
  • tests/regressiontests/forms/regressions.py

     
    4141...     somechoice = ChoiceField(choices=GENDERS, widget=RadioSelect(), label=u'\xc5\xf8\xdf')
    4242>>> f = SomeForm()
    4343>>> f.as_p()
    44 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>'
     44u'<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>'
    4545
    4646Testing choice validation with UTF-8 bytestrings as input (these are the
    4747Russian abbreviations "мес." and "шт.".
     
    5757>>> activate('ru')
    5858>>> f = SomeForm({})
    5959>>> f.as_p()
    60 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>'
     60u'<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>'
    6161>>> deactivate()
    6262
    6363Deep copying translated text shouldn't raise an error
  • tests/regressiontests/forms/forms.py

     
    423423zero-based index.
    424424>>> f = FrameworkForm(auto_id='id_%s')
    425425>>> print f['language']
    426 <ul>
     426<ul id="id_language">
    427427<li><label><input type="radio" id="id_language_0" value="P" name="language" /> Python</label></li>
    428428<li><label><input type="radio" id="id_language_1" value="J" name="language" /> Java</label></li>
    429429</ul>
     
    433433ID of the *first* radio button.
    434434>>> print f
    435435<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">
    437437<li><label><input type="radio" id="id_language_0" value="P" name="language" /> Python</label></li>
    438438<li><label><input type="radio" id="id_language_1" value="J" name="language" /> Java</label></li>
    439439</ul></td></tr>
    440440>>> print f.as_ul()
    441441<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">
    443443<li><label><input type="radio" id="id_language_0" value="P" name="language" /> Python</label></li>
    444444<li><label><input type="radio" id="id_language_1" value="J" name="language" /> Java</label></li>
    445445</ul></li>
    446446>>> print f.as_p()
    447447<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">
    449449<li><label><input type="radio" id="id_language_0" value="P" name="language" /> Python</label></li>
    450450<li><label><input type="radio" id="id_language_1" value="J" name="language" /> Java</label></li>
    451451</ul></p>
  • tests/regressiontests/forms/widgets.py

     
    684684# Attributes provided at instantiation are passed to the constituent inputs
    685685>>> w = RadioSelect(attrs={'id':'foo'})
    686686>>> print w.render('beatle', 'J', choices=(('J', 'John'), ('P', 'Paul'), ('G', 'George'), ('R', 'Ringo')))
    687 <ul>
     687<ul id="foo">
    688688<li><label><input checked="checked" type="radio" id="foo_0" value="J" name="beatle" /> John</label></li>
    689689<li><label><input type="radio" id="foo_1" value="P" name="beatle" /> Paul</label></li>
    690690<li><label><input type="radio" id="foo_2" value="G" name="beatle" /> George</label></li>
     
    694694# Attributes provided at render-time are passed to the constituent inputs
    695695>>> w = RadioSelect()
    696696>>> print w.render('beatle', 'J', choices=(('J', 'John'), ('P', 'Paul'), ('G', 'George'), ('R', 'Ringo')), attrs={'id':'bar'})
    697 <ul>
     697<ul id="bar">
    698698<li><label><input checked="checked" type="radio" id="bar_0" value="J" name="beatle" /> John</label></li>
    699699<li><label><input type="radio" id="bar_1" value="P" name="beatle" /> Paul</label></li>
    700700<li><label><input type="radio" id="bar_2" value="G" name="beatle" /> George</label></li>
Back to Top