> I too spent a day or so on this seemingly simple problem :(
> Here's my solution...
>
> class EMailAddressForm(forms.Form):
>
> emailType = forms.ChoiceField(required=True,choices=[])
>
> def __init__(self, *args, **kwargs):
> super(forms.Form, self).__init__(*args, **kwargs)
> choices = EMailType.objects.all()
> et = []
> for c in choices:
> et.append((c.e_mail_type,c.e_mail_type))
> self.fields['emailType'].choices = et
>
> In my view function (note the value set should be the 'value', not the
> 'label'...
>
> for e in emails:
> emailData.append({'emailType': e.e_mail_type,
>
> })
>
> email_formset = EMailFormSet(initial=emailData, prefix='emails')
> # I don't know if this code below is necessary or not.
> email_index = 0
> for e in emails:
> email_formset.forms[email_index].fields
> ['emailType'].selected_choices = e.e_mail_type
> email_index += 1
>
Thank you I'll check the implementation here ..
Leonel
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---