[EMAIL PROTECTED] skrev:
> I am still having problems setting  the select widget to the 3rd value in the 
> drop  down list.
> Looking further it seems that the html does not have the selected="selected" 
> value in any of the items.
> The documentation states that if use a bound form you will see that in the 
> html.

"initial" data are showed in an UNBOUND form. If the form is bound, it
shows the data you bound it to. This is clearly stated in the
documentation - I assume you mistyped here.

> How would you go about getting the selected value in the html for a 
> choicefield. I tried the initial parameter in the choicefield and that does 
> not change which value is selected. It always happens to be the first in the 
> list.
>
> Any help would greatly appreciated.

For an unbound form, it works for me:

"""
$ cat forms.py
from django import newforms as forms

class SearchForm (forms.Form):
        campaign = forms.ChoiceField(required=False,choices
=(('choice1','Choice1'),('choice2','Choice 2')), initial = 'choice2' )
sf = SearchForm()
print sf

$ python forms.py
<tr><th><label for="id_campaign">Campaign:</label></th><td><select
name="campaign" id="id_campaign">
<option value="choice1">Choice1</option>
<option value="choice2" selected="selected">Choice 2</option>
</select></td></tr>
"""

Can you please

a) Confirm that the above works for you
b) Post a self-contained example which shows your problem

Nis


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