Fix pick_multi only returning one answer as maximum.
authorDaniel Diniz <ajaksu@gmail.com>
Fri, 03 Jul 2009 15:21:44 +0200
changeset 2507 4a6b8d6674b6
parent 2506 c98bf890156e
child 2508 17caa9f1c683
Fix pick_multi only returning one answer as maximum. Reviewed by: Lennard de Rijk
app/soc/views/helper/surveys.py
--- a/app/soc/views/helper/surveys.py	Fri Jul 03 15:00:00 2009 +0200
+++ b/app/soc/views/helper/surveys.py	Fri Jul 03 15:21:44 2009 +0200
@@ -139,6 +139,9 @@
       else:
         extra_attrs['disabled'] = 'disabled'
 
+    # flag whether we can use getlist to retrieve multiple values
+    is_post = hasattr(post_dict, 'getlist')
+
     # add unordered fields to self.survey_fields
     for field in self.survey_content.dynamic_properties():
 
@@ -150,7 +153,10 @@
 
       if has_record and field in post_dict:
         # entered value that is not yet saved
-        value = post_dict[field]
+        if schema.getType(field) == 'pick_multi' and is_post:
+          value = post_dict.getlist(field)
+        else:
+          value = post_dict[field]
         if COMMENT_PREFIX + field in post_dict:
           comment = post_dict[COMMENT_PREFIX + field]
       elif has_record and hasattr(self.survey_record, field):