Multiple choice nonrequired questions now accept empty answers.
authorDaniel Hans <Daniel.M.Hans@gmail.com>
Fri, 30 Oct 2009 22:24:34 +0100
changeset 3069 1b9c554ca96d
parent 3068 1e01ffe9cc61
child 3070 afd98e17a2b2
Multiple choice nonrequired questions now accept empty answers. The change is mostly concerned with issue 674, probably fixing it.
app/soc/views/helper/surveys.py
--- a/app/soc/views/helper/surveys.py	Fri Oct 30 12:40:56 2009 +0100
+++ b/app/soc/views/helper/surveys.py	Fri Oct 30 22:24:34 2009 +0100
@@ -803,6 +803,14 @@
   def __init__(self, *args, **kwargs):
     super(PickManyField, self).__init__(*args, **kwargs)
 
+  def clean(self, value):
+    """Validates that the input is a list or tuple. If no fields are marked,
+    an empty string is returned istead of an empty list.
+    """
+    
+    value = super(PickManyField, self).clean(value)
+    return value if value else ''
+
 
 class PickQuantField(forms.ChoiceField):
   """Stub for customizing the choice field.