I've made a couple of forms that are basically supposed to dump their
content into an email and send that on. My forms both inherit this class:

class EmailForm(forms.Form):
    def sendemail(self, fromAdd, toAdd, subject, keys=None):
        body = ''

        if not keys: keys = self.cleaned_data.keys()
        for k in keys:
            body = '%s%s: %s\n' % (body, k, self.cleaned_data[k])

        send_mail(subject, body, fromAdd, ['o...@....com'],
fail_silently=False)

        return "Thank you. Your form has submitted sucessfully."

If you're confused as to what *fields* is, it's just an override so I can
pass in a custom order of the field names.

That results in an email like this:

> field1: value
> field2: value
> etc


All very good, but it's a little cryptic for one of my forms where there are
lots and lots of fields. Instead of using the raw field name, can I grab the
label?

I also have some complex field types (multiple choice and a select). Rather
than the HTML value being used, can I pass out the nice name that gets shown
to the person filling the form out?

--~--~---------~--~----~------------~-------~--~----~
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