#5033: Dynamic initial values for MultipleChoiceFields in newforms
------------------------------+---------------------------------------------
Reporter:  [EMAIL PROTECTED]  |       Owner:  jacob                             
           
  Status:  new                |   Component:  Documentation                     
           
 Version:  SVN                |    Keywords:  dynamic values, 
MultipleChoiceField, newforms
   Stage:  Unreviewed         |   Has_patch:  0                                 
           
------------------------------+---------------------------------------------
 The newforms documentation specifies that forms can be pre-populated with
 dynamic values using an 'initial' dictionary. From the docs:
 
 
 {{{
 >>> class CommentForm(forms.Form):
 ...     name = forms.CharField()
 ...     url = forms.URLField()
 ...     comment = forms.CharField()
 >>> f = CommentForm(initial={'name': 'your username'}, auto_id=False)
 >>> print f
 <tr><th>Name:</th><td><input type="text" name="name" value="your username"
 /></td></tr>
 ...
 }}}
 
 This works fine if the form element is a CharField as in the example
 above. However, if the form element is a MultipleChoiceField, the initial
 value is required to be the {{{id}}} of the object you're trying to select
 - not the string representation as required for CharField, TextField et
 al.
 
 It's fairly obvious when you think about it, but it would have saved me
 some time if the docs mentioned it.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/5033>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" 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-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to