Ahh, that was it. Thanks for the help. I was doing this....

data.comments = $(form).find('inp...@name=comments]').val();

instead of...

data.comments = $(form).find('textar...@name=comments]').val();


Thank you!

On Jan 25, 3:26 pm, Daniel Roseman <roseman.dan...@googlemail.com>
wrote:
> On Jan 25, 7:51 pm, issya <floridali...@gmail.com> wrote:
>
>
>
> > I am making a modelform that looks like the below.
>
> > class ContactForm(forms.ModelForm):
> >         name = forms.CharField(widget=forms.TextInput(attrs=
> > {'class':'required'}))
> >         phone = forms.CharField(widget=forms.TextInput(attrs=
> > {'class':'required'}))
> >         comments = forms.CharField(widget=forms.Textarea(attrs={'rows':4}))
> >         class Meta:
> >                 model = Leads
> >                 exclude = ( 'mls_listing_id',
> >                                         'friends_email')
>
> > Here is a snippet from a view.
>
> > def contact(request):
> >         if request.method == 'POST': # If the form has been submitted...
> >                 form = ContactForm(request.POST, instance=Leads()) # A form 
> > bound to
> > the POST data
> >                 if form.is_valid(): # All validation rules pass
> >                         print form.cleaned_data['comments']
>
> > It always printe the comments data as the word undefined. This happens
> > no matter if it is filled in or not. Any idea what is going on here?
> > If I take the Textarea widget off it is fine.
>
> 'undefined' is not a Python value, but a Javascript one. Is it
> possible that you have some Javascript running on your form page -
> possibly an onsubmit handler - with a bug that's causing it to replace
> the value of the textarea with 'undefined'?
>
> It might help to add the line
>     print request.POST['comments']
> before the form instantiation, to show that the value 'undefined' is
> actually coming from the POST rather than being inserted by Django.
> --
> DR.
--~--~---------~--~----~------------~-------~--~----~
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