Many thanks Honza!

I modified my Form class as follows (this is the complete form class,
not just a fragment...sorry for all of the choppy lines.  Trying to
keep from wrapping in the wrong place):

class AddEditContactHistoryForm(forms.Form):
   customer_id = forms.Field(
       widget=forms.HiddenInput,required=False)
   contact_history_type_id = forms.ChoiceField(
           label='Contact Type',
           choices=[(c.id,c.description)
           for c in ContactHistoryType.objects.all()])
   employee_id = forms.ChoiceField(
       label='Employee', required=False)
   summary =
       forms.CharField(widget=forms.Textarea(
       attrs={'rows': '4',}),required=False)
   date_opened = forms.DateField(initial=date.today())
   next_action_date = forms.DateField(
       label='Next Action Date', required=False)
   status_id = forms.ChoiceField(label='Status',
       choices=[(c.id,c.description)
       for c in ContactHistoryStatus.objects.all()])
   priority_id = forms.ChoiceField(
       label='Priority', choices=[(c.id,c.description)
       for c in ContactHistoryPriority.objects.all()])
   cost = forms.CharField(required=False)
   assigned_to_id = forms.ChoiceField(
       label='Assigned To',required=False,
       choices=[('','Select')] + [(c.id,c.username)
       for c in User.objects.all()])
   product_version_id = forms.ChoiceField(
       required=False,label='Product/Version',
       choices=[('','Select')] + [(p.id,"%s (%s)" %
       (p.product.name,p.version_number))
       for p in ProductVersion.objects.all()])
   def __init__(self, data=None, auto_id='id_%s',
       prefix=None, employee_list={}):
       super( AddEditContactHistoryForm, self ).__init__(
           data,auto_id,prefix )
       self.fields['employee_id'] = forms.ChoiceField(
           label='Employee', required=False,
           choices = [('','Select')] + [(c.id,"%s, %s (%s)" %
           (c.person.last_name,c.person.first_name,c.title))
           for c in employee_list] )

This works just fine.  Notice that I did have to leave the initial
declaration of employee_id in its place and then re-created it in
__init__.  This was so the element would show up at the correct place
in the rendered form.

--gordon


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