I just ran into this myself, yesterday and found the solution by perusing the django source code. Your form class (MyClass) will have had a field called "fields" created by the meta class of the base form. That field will have a choices field that you can set. In your setChoice method (which, by the way, I think should take a "self" parameter if you wish to get at your instance state), you can use the following to set the choices for your state_txt field:
self.fields['state_txt'].choices = (tuple of allowed choices) -- Eric On Sep 30, 1:37 pm, alan <[EMAIL PROTECTED]> wrote: > I'm having trouble dynamically assigning the choices to a ChoiceField. > > My ChoiceField stores an object's state. In the template pulldown for > this field, I want to restrict the user to only go from stateA to > StateB; from stateB to stateC, etc. Hence the allowable choices need > to be a set based on the current state (and also user privilege). How > do I do this? > > For example > class MyClass(ModelForm) > state_txt = forms.ChoiceField(choices=setChoice()) > ... > def setChoice(): > currentState = ???? #how to get the current object's > state > if currentState == 'stateA': > return [('stateB','stateB')] > elif currentState == 'stateB': > return [('stateC','stateC')] > ... --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---