On Feb 17, 7:05 pm, "paulh" <[EMAIL PROTECTED]> wrote:
> I feel the following should work:
> class Myform(forms.Form):
> ...publ = forms.ChoiceField(label='Publisher', required=False)
>
> and then in handler I should be able to set the choices dynamically
> by:
>
> def meth(request):
> ...frm=Myform(initial={'publ':((1,2),(2,3),(3,4)))}) #even if the
> brackets are wrong here, they were right in the original
>

That shouldn't work as initial is meant to set the value of a field.

I had the same problem and a peek at the source told me that a
ChoiceField has a 'choices' attribute which is settable so:

form = MyForm(...)
form.fields['publ'].choices = ((1,2),(2,3),(3,4))

will work, but I don't know whether it is the right thing to do (TM).

--
Arnaud


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to