diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/newforms.txt | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/docs/newforms.txt b/docs/newforms.txt index 593e9216d7..5feb2e6a02 100644 --- a/docs/newforms.txt +++ b/docs/newforms.txt @@ -1849,7 +1849,11 @@ In addition, each generated form field has attributes set as follows: * If the model field has ``choices`` set, then the form field's ``widget`` will be set to ``Select``, with choices coming from the model field's - ``choices``. + ``choices``. The choices will normally include the blank choice which is + selected by default. If the field is required, this forces the user to + make a selection. The blank choice will not be included if the model + field has ``blank=False`` and an explicit ``default`` value (the + ``default`` value will be initially selected instead). Finally, note that you can override the form field used for a given model field. See "Overriding the default field types" below. @@ -2095,10 +2099,14 @@ instance instead of a model class:: # Instantiate the form. >>> f = AuthorForm() -When a form created by ``form_for_instance()`` is created, the initial -data values for the form fields are drawn from the instance. However, -this data is not bound to the form. You will need to bind data to the -form before the form can be saved. +When a form created by ``form_for_instance()`` is created, the initial data +values for the form fields are drawn from the instance. However, this data is +not bound to the form. You will need to bind data to the form before the form +can be saved. + +Unlike ``form_for_model()``, a choice field in form created by +``form_for_instance()`` will not include the blank choice if the respective +model field has ``blank=False``. The initial choice is drawn from the instance. When you call ``save()`` on a form created by ``form_for_instance()``, the database instance will be updated. As in ``form_for_model()``, ``save()`` |
