diff options
| author | Jannis Leidel <jannis@leidel.info> | 2010-10-01 02:02:58 +0000 |
|---|---|---|
| committer | Jannis Leidel <jannis@leidel.info> | 2010-10-01 02:02:58 +0000 |
| commit | 392d992f8295f96632179e01e790465cc9c8d3ec (patch) | |
| tree | bc1d6e3b0819f1b2a58a91d146fa6eb112d8396d /docs | |
| parent | a64e96c227b36c701a86ded75d839b1cd2442713 (diff) | |
Fixed #7048 -- Added ClearableFileInput widget to clear file fields. Thanks for report and patch, jarrow and Carl Meyer.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@13968 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/forms/fields.txt | 4 | ||||
| -rw-r--r-- | docs/ref/forms/widgets.txt | 8 | ||||
| -rw-r--r-- | docs/releases/1.3.txt | 25 |
3 files changed, 35 insertions, 2 deletions
diff --git a/docs/ref/forms/fields.txt b/docs/ref/forms/fields.txt index 0dd9095a77..d2b1c303ed 100644 --- a/docs/ref/forms/fields.txt +++ b/docs/ref/forms/fields.txt @@ -507,7 +507,7 @@ given length. .. class:: FileField(**kwargs) - * Default widget: ``FileInput`` + * Default widget: ``ClearableFileInput`` * Empty value: ``None`` * Normalizes to: An ``UploadedFile`` object that wraps the file content and file name into a single object. @@ -573,7 +573,7 @@ These control the range of values permitted in the field. .. class:: ImageField(**kwargs) - * Default widget: ``FileInput`` + * Default widget: ``ClearableFileInput`` * Empty value: ``None`` * Normalizes to: An ``UploadedFile`` object that wraps the file content and file name into a single object. diff --git a/docs/ref/forms/widgets.txt b/docs/ref/forms/widgets.txt index 05215d4d8e..c01a7368bd 100644 --- a/docs/ref/forms/widgets.txt +++ b/docs/ref/forms/widgets.txt @@ -46,6 +46,14 @@ commonly used groups of widgets: File upload input: ``<input type='file' ...>`` +.. class:: ClearableFileInput + + .. versionadded:: 1.3 + + File upload input: ``<input type='file' ...>``, with an additional checkbox + input to clear the field's value, if the field is not required and has + initial data. + .. class:: DateInput .. versionadded:: 1.1 diff --git a/docs/releases/1.3.txt b/docs/releases/1.3.txt index 51de6fdd92..aaee5d8ef2 100644 --- a/docs/releases/1.3.txt +++ b/docs/releases/1.3.txt @@ -42,6 +42,31 @@ custom widget to your form that sets the ``render_value`` argument:: username = forms.CharField(max_length=100) password = forms.PasswordField(widget=forms.PasswordInput(render_value=True)) +Clearable default widget for FileField +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Django 1.3 now includes a ``ClearableFileInput`` form widget in addition to +``FileInput``. ``ClearableFileInput`` renders with a checkbox to clear the +field's value (if the field has a value and is not required); ``FileInput`` +provided no means for clearing an existing file from a ``FileField``. + +``ClearableFileInput`` is now the default widget for a ``FileField``, so +existing forms including ``FileField`` without assigning a custom widget will +need to account for the possible extra checkbox in the rendered form output. + +To return to the previous rendering (without the ability to clear the +``FileField``), use the ``FileInput`` widget in place of +``ClearableFileInput``. For instance, in a ``ModelForm`` for a hypothetical +``Document`` model with a ``FileField`` named ``document``:: + + from django import forms + from myapp.models import Document + + class DocumentForm(forms.ModelForm): + class Meta: + model = Document + widgets = {'document': forms.FileInput} + .. _deprecated-features-1.3: Features deprecated in 1.3 |
