diff options
Diffstat (limited to 'django/forms/widgets.py')
-rw-r--r-- | django/forms/widgets.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/django/forms/widgets.py b/django/forms/widgets.py index 3d6091c250..b4a9583364 100644 --- a/django/forms/widgets.py +++ b/django/forms/widgets.py @@ -433,6 +433,7 @@ class ClearableFileInput(FileInput): initial_text = _("Currently") input_text = _("Change") template_name = "django/forms/widgets/clearable_file_input.html" + checked = False def clear_checkbox_name(self, name): """ @@ -475,10 +476,12 @@ class ClearableFileInput(FileInput): } ) context["widget"]["attrs"].setdefault("disabled", False) + context["widget"]["attrs"]["checked"] = self.checked return context def value_from_datadict(self, data, files, name): upload = super().value_from_datadict(data, files, name) + self.checked = self.clear_checkbox_name(name) in data if not self.is_required and CheckboxInput().value_from_datadict( data, files, self.clear_checkbox_name(name) ): |