Ticket #5469: docs_newforms_txt.diff
File docs_newforms_txt.diff, 1.4 KB (added by , 17 years ago) |
---|
-
docs/newforms.txt
981 981 >>> f.errors 982 982 {'url': [u'This field is required.'], 'name': [u'This field is required.']} 983 983 984 984 985 ``widget`` 985 986 ~~~~~~~~~~ 986 987 … … 1052 1053 displayed for unbound forms, and they're not used as fallback values if a 1053 1054 particular value isn't provided. 1054 1055 1056 Note that ``initial`` values are *not* cleaned. It is supposed that values are right, unlike ``data`` values:: 1057 1058 >>> class NewsForm(forms.Form): 1059 ... date = forms.DateField() 1060 ... title = forms.CharField() 1061 >>> f = NewsForm(initial={'date': 'not_a_date'}) 1062 >>> f.as_table() 1063 <tr><th><label for="id_date">Date:</label></th><td><input type="text" name="date" value="not_a_date" id="id_date" /></td></tr> 1064 <tr><th><label for="id_title">Title:</label></th><td><input type="text" name="title" id="id_title" /></td></tr> 1065 1066 This also means that for a ``MultiValueField``, you need to pass in the data as one value, not as the individual subfields. 1067 1055 1068 Finally, note that if a ``Field`` defines ``initial`` *and* you include 1056 1069 ``initial`` when instantiating the ``Form``, then the latter ``initial`` will 1057 1070 have precedence. In this example, ``initial`` is provided both at the field