[Django] #36136: New form field for toggle inputs

8 views
Skip to first unread message

Django

unread,
Jan 24, 2025, 4:03:04 AM1/24/25
to django-...@googlegroups.com
#36136: New form field for toggle inputs
-------------------------------------+-------------------------------------
Reporter: Hristo Trendafilov | Type: New
| feature
Status: new | Component: Forms
Version: | Severity: Normal
Keywords: togglefield, | Triage Stage:
toggle, field | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Toggle inputs are quite common web elements and are widely used in modern
web pages, CSS frameworks, etc.

Those could be narrowed down to the `BooleanField` but with several key
differences:

- They never be required, even if defied like so;
- They should always return cleaned data to be `False` if not passed in
the form data;
- They should always have an initial value of `False` unless explicitly
defined;
- They have a special widget, based on the CheckboxInput, but adding
`role="switch"` and `aria-checked="false/true"`/based on the value/;
--
Ticket URL: <https://code.djangoproject.com/ticket/36136>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 24, 2025, 4:34:42 AM1/24/25
to django-...@googlegroups.com
#36136: New form field for toggle inputs
-------------------------------------+-------------------------------------
Reporter: Hristo Trendafilov | Owner: (none)
Type: New feature | Status: new
Component: Forms | Version:
Severity: Normal | Resolution:
Keywords: togglefield, | Triage Stage:
toggle, field | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Hristo Trendafilov:

Old description:

> Toggle inputs are quite common web elements and are widely used in modern
> web pages, CSS frameworks, etc.
>
> Those could be narrowed down to the `BooleanField` but with several key
> differences:
>
> - They never be required, even if defied like so;
> - They should always return cleaned data to be `False` if not passed in
> the form data;
> - They should always have an initial value of `False` unless explicitly
> defined;
> - They have a special widget, based on the CheckboxInput, but adding
> `role="switch"` and `aria-checked="false/true"`/based on the value/;

New description:

Toggle inputs are quite common web elements and are widely used in modern
web pages, CSS frameworks, etc.

Those could be narrowed down to the `BooleanField` but with several key
differences:

- They never be required, even if defied like so;
- They should always return cleaned data to be `False` if not passed in
the form data;
- They should always have an initial value of `False` unless explicitly
defined;
- On invalid form data those should not raise ValidationError, but cast
the value to `False`;
- They have a special widget, based on the CheckboxInput, but adding
`role="switch"` and `aria-checked="false/true"`/based on the value/;

--
--
Ticket URL: <https://code.djangoproject.com/ticket/36136#comment:1>

Django

unread,
Jan 24, 2025, 4:58:16 AM1/24/25
to django-...@googlegroups.com
#36136: New form field for toggle inputs
-------------------------------------+-------------------------------------
Reporter: Hristo Trendafilov | Owner: (none)
Type: New feature | Status: closed
Component: Forms | Version:
Severity: Normal | Resolution: wontfix
Keywords: togglefield, | Triage Stage:
toggle, field | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* resolution: => wontfix
* status: new => closed

Comment:

As you are requesting a new feature for Django, you need to first propose
and discuss the idea with the community and gain consensus. To do that,
please consider starting a new conversation on the
[https://forum.djangoproject.com/c/internals/5 Django Forum], where you'll
reach a broader audience and receive additional feedback.

Personally, I don't see a strong reason to add this to core considering
folks can write their own custom widgets.

I'll close the ticket for now, but if the community agrees with the
proposal, please return to this ticket and reference the forum discussion
so we can re-open it. For more information, please refer to
[https://docs.djangoproject.com/en/stable/internals/contributing/bugs-and-
features/#requesting-features the documented guidelines for requesting
features].

Thanks!
--
Ticket URL: <https://code.djangoproject.com/ticket/36136#comment:2>
Reply all
Reply to author
Forward
0 new messages