mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #31118 -- Made FileInput to avoid the required attribute when initial data exists.
This commit is contained in:
committed by
Mariusz Felisiak
parent
53d8646f79
commit
ffcf1a8ebf
@@ -325,17 +325,22 @@ foundation for custom widgets.
|
||||
to display the ``required`` attribute for each field.
|
||||
|
||||
By default, returns ``False`` for hidden widgets and ``True``
|
||||
otherwise. Special cases are :class:`~django.forms.ClearableFileInput`,
|
||||
which returns ``False`` when ``initial`` is set, and
|
||||
:class:`~django.forms.CheckboxSelectMultiple`, which always returns
|
||||
``False`` because browser validation would require all checkboxes to be
|
||||
checked instead of at least one.
|
||||
otherwise. Special cases are :class:`~django.forms.FileInput` and
|
||||
:class:`~django.forms.ClearableFileInput`, which return ``False`` when
|
||||
``initial`` is set, and :class:`~django.forms.CheckboxSelectMultiple`,
|
||||
which always returns ``False`` because browser validation would require
|
||||
all checkboxes to be checked instead of at least one.
|
||||
|
||||
Override this method in custom widgets that aren't compatible with
|
||||
browser validation. For example, a WSYSIWG text editor widget backed by
|
||||
a hidden ``textarea`` element may want to always return ``False`` to
|
||||
avoid browser validation on the hidden field.
|
||||
|
||||
.. versionchanged:: 3.1
|
||||
|
||||
In older versions, ``True`` was returned for
|
||||
:class:`~django.forms.FileInput` when ``initial`` was set.
|
||||
|
||||
``MultiWidget``
|
||||
---------------
|
||||
|
||||
|
||||
@@ -406,6 +406,9 @@ Miscellaneous
|
||||
* Date-only formats are removed from the default list for
|
||||
:setting:`DATETIME_INPUT_FORMATS`.
|
||||
|
||||
* The :class:`~django.forms.FileInput` widget no longer renders with the
|
||||
``required`` HTML attribute when initial data exists.
|
||||
|
||||
.. _deprecated-features-3.1:
|
||||
|
||||
Features deprecated in 3.1
|
||||
|
||||
Reference in New Issue
Block a user