Author: adrian
Date: 2007-01-10 17:25:29 -0600 (Wed, 10 Jan 2007)
New Revision: 4304
Modified:
django/trunk/django/newforms/widgets.py
django/trunk/tests/regressiontests/forms/tests.py
Log:
Fixed #3266 -- newforms: Made RadioSelect accept funky characters. Thanks for
reporting, Honza Kral
Modified: django/trunk/django/newforms/widgets.py
===================================================================
--- django/trunk/django/newforms/widgets.py 2007-01-10 22:46:06 UTC (rev
4303)
+++ django/trunk/django/newforms/widgets.py 2007-01-10 23:25:29 UTC (rev
4304)
@@ -172,14 +172,15 @@
def __init__(self, name, value, attrs, choice, index):
self.name, self.value = name, value
self.attrs = attrs
- self.choice_value, self.choice_label = choice
+ self.choice_value = smart_unicode(choice[0])
+ self.choice_label = smart_unicode(choice[1])
self.index = index
def __unicode__(self):
return u'<label>%s %s</label>' % (self.tag(), self.choice_label)
def is_checked(self):
- return self.value == smart_unicode(self.choice_value)
+ return self.value == self.choice_value
def tag(self):
if self.attrs.has_key('id'):
Modified: django/trunk/tests/regressiontests/forms/tests.py
===================================================================
--- django/trunk/tests/regressiontests/forms/tests.py 2007-01-10 22:46:06 UTC
(rev 4303)
+++ django/trunk/tests/regressiontests/forms/tests.py 2007-01-10 23:25:29 UTC
(rev 4304)
@@ -527,12 +527,16 @@
>>> r[1].is_checked()
False
>>> r[1].name, r[1].value, r[1].choice_value, r[1].choice_label
-('beatle', u'J', 'P', 'Paul')
+('beatle', u'J', u'P', u'Paul')
>>> r[10]
Traceback (most recent call last):
...
IndexError: list index out of range
+>>> w = RadioSelect()
+>>> unicode(w.render('email', 'ŠĐĆŽćžšđ', choices=[('ŠĐĆŽćžšđ',
'ŠĐabcĆŽćžšđ'), ('ćžšđ', 'abcćžšđ')]))
+u'<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>'
+
# CheckboxSelectMultiple Widget ###############################################
>>> w = CheckboxSelectMultiple()
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---