sdi/forms.py
branchanoop
changeset 93 505989755cd8
parent 90 1a6e1af98624
child 124 d4a7644e7fe8
--- a/sdi/forms.py	Wed Jul 14 21:04:59 2010 +0530
+++ b/sdi/forms.py	Thu Jul 15 01:06:32 2010 +0530
@@ -168,11 +168,16 @@
 
         return username
 
-def UserSelectForm(users):
+def UserSelectForm(users, post_data=None ):
 
     choices = [ (_.id, _.first_name) for _ in users ]
     class myF(forms.Form):
 
         selected_users = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple, choices=choices, required=False)
 
-    return myF()
+        def clean_selected_users(self):
+            selected_ids = self.cleaned_data['selected_users']
+            return [ Registrant.objects.get(id=_) for _ in selected_ids ]
+
+    return myF(post_data) if post_data else myF()
+