Django

Code

Changeset 4304

Show
Ignore:
Timestamp:
01/10/07 17:25:29 (2 years ago)
Author:
adrian
Message:

Fixed #3266 -- newforms: Made RadioSelect? accept funky characters. Thanks for reporting, Honza Kral

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/newforms/widgets.py

    r4298 r4304  
    173173        self.name, self.value = name, value 
    174174        self.attrs = attrs 
    175         self.choice_value, self.choice_label = choice 
     175        self.choice_value = smart_unicode(choice[0]) 
     176        self.choice_label = smart_unicode(choice[1]) 
    176177        self.index = index 
    177178 
     
    180181 
    181182    def is_checked(self): 
    182         return self.value == smart_unicode(self.choice_value) 
     183        return self.value == self.choice_value 
    183184 
    184185    def tag(self): 
  • django/trunk/tests/regressiontests/forms/tests.py

    r4303 r4304  
    528528False 
    529529>>> r[1].name, r[1].value, r[1].choice_value, r[1].choice_label 
    530 ('beatle', u'J', 'P', 'Paul') 
     530('beatle', u'J', u'P', u'Paul') 
    531531>>> r[10] 
    532532Traceback (most recent call last): 
    533533... 
    534534IndexError: list index out of range 
     535 
     536>>> w = RadioSelect() 
     537>>> unicode(w.render('email', 'ŠĐĆŽćžšđ', choices=[('ŠĐĆŽćžšđ', 'ŠĐabcĆŽćžšđ'), ('ćžšđ', 'abcćžšđ')])) 
     538u'<ul>\n<li><label><input checked="checked" type="radio" name="email" value="\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111" /> \u0160\u0110abc\u0106\u017d\u0107\u017e\u0161\u0111</label></li>\n<li><label><input type="radio" name="email" value="\u0107\u017e\u0161\u0111" /> abc\u0107\u017e\u0161\u0111</label></li>\n</ul>' 
    535539 
    536540# CheckboxSelectMultiple Widget ###############################################