Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed documentation of Widget.id_for_label() empty return value. #15288

Merged
merged 1 commit into from Jun 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions django/forms/widgets.py
Expand Up @@ -301,8 +301,8 @@ def value_omitted_from_data(self, data, files, name):

def id_for_label(self, id_):
"""
Return the HTML ID attribute of this Widget for use by a <label>,
given the ID of the field. Return None if no ID is available.
Return the HTML ID attribute of this Widget for use by a <label>, given
the ID of the field. Return an empty string if no ID is available.

This hook is necessary because some widgets have multiple HTML
elements and, thus, multiple IDs. In that case, this method should
Expand Down
3 changes: 2 additions & 1 deletion docs/ref/forms/widgets.txt
Expand Up @@ -277,7 +277,8 @@ foundation for custom widgets.
.. method:: id_for_label(id_)

Returns the HTML ID attribute of this widget for use by a ``<label>``,
given the ID of the field. Returns ``None`` if an ID isn't available.
given the ID of the field. Returns an empty string if an ID isn't
available.

This hook is necessary because some widgets have multiple HTML
elements and, thus, multiple IDs. In that case, this method should
Expand Down