On May 17, 4:23 pm, Bobby Roberts <tchend...@gmail.com> wrote:
> > ...     users = forms.ModelMultipleChoiceField(
> > ...         queryset=User.objects,
> > ...         widget=forms.CheckboxSelectMultiple,
> > ...         required=True)
> > ...>>> User(username='sdc').save()
> > >>> User(username='bobby').save()
>

ok so here's what i have so far:

class FrmIdMessage (forms.Form):
    posted_to = forms.ModelMultipleChoiceField (queryset=User.objects,
required=True,widget=forms.CheckboxSelectMultiple())
    message = forms.CharField (max_length=300, required=True,
widget=forms.Textarea(attrs={'class':'smallblob'}))



in my view i have this:


    if request.method=='POST':
        form=FrmIdMessage(request.POST)
        if form.is_valid():   #process valid form here
            assert False, request.POST.get('posted_to','')
[snip]



The only that prints out is:

2

which represents the last textbox checked.  The HTML generated by the
form.py includes:

<li><label for="id_posted_to_0"><input type="checkbox"
name="posted_to" value="1" id="id_posted_to_0" /> admin</label></li>
<li><label for="id_posted_to_1"><input type="checkbox"
name="posted_to" value="2" id="id_posted_to_1" /> test</label></li>
<li><label for="id_posted_to_2"><input type="checkbox"
name="posted_to" value="4" id="id_posted_to_2" /> test2</label></li>


all of these checkboxes have the same name.  Why isn't this passed
back to forms.py as a list?  How can i get all of the values for the
checkboxes if i check all three?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to