From d75e23ce9ba57af9e63a824a54249bbfb0edce99 Mon Sep 17 00:00:00 2001 From: Joseph Kocherhans Date: Tue, 23 Feb 2010 23:48:44 +0000 Subject: [1.1.X] Fixed #9336. Changed CheckboxInput to render 'True' and 'False' input strings as checked or not instead of as a value attribute. Backport of r12556 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12557 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/forms/widgets.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'django/forms') diff --git a/django/forms/widgets.py b/django/forms/widgets.py index a759581205..a39c19872e 100644 --- a/django/forms/widgets.py +++ b/django/forms/widgets.py @@ -384,7 +384,12 @@ class CheckboxInput(Widget): # A missing value means False because HTML form submission does not # send results for unselected checkboxes. return False - return super(CheckboxInput, self).value_from_datadict(data, files, name) + value = data.get(name) + # Translate true and false strings to boolean values. + values = {'true': True, 'false': False} + if isinstance(value, basestring): + value = values.get(value.lower(), value) + return value def _has_changed(self, initial, data): # Sometimes data or initial could be None or u'' which should be the -- cgit v1.3