Problem/Motivation
With the Checkboxes element Drupal provides a super helpful form elment to show a list of checkboxes.
For more complex cases, especially with several columns, there's Tableselect.
Creating forms with many options in the Checkboxes Element leads to bad UX, if you have to select all checkboxes one by one.
Instead, the Drupal Elements should provide good UX and DX out of the box and that way also ensure consistency.
For that reason, I'd like to propose introducing a'#checkall' => TRUE / FALSE
option for Checkboxes.
There have been several requests for that in the past, see below, so I think it makes sense.
Initially, I created my request for the "(Un)check all" feature in a field_tools issue, but @joachim correctly pointed out that it would make more sense to have this functionality generally available in Drupal Core Checkboxes element:
It would be useful, but I'd rather see that implemented in the core checkboxes element that in this module.
Also see the positive feedback by Chris Matthews in #19:
Personally +1 for bringing multiple_select type functionality generally into core. Basically standard UX on the web, but up to the UX team/maintainers to decide.
Helpful comments in #3 from 12 years ago
I'd be in support of expanding #type=checkboxes to allow this property, as we do with #type=tableselect.
Other than the permissions page (where I assume you would be suggesting a select all at the top of each role column, can you suggest anywhere else in Core that you think this would be appropriate?
I don't personally think that this is appropriate on the permissions page, how many times do you want to give a role all permissions, and how often do you do this (one per install)?
Related modules:
- https://www.drupal.org/project/checkall_widget (D8+, jQuery)
- https://www.drupal.org/project/checkboxesjs (D8+, jQuery, Thrid party library)
- https://www.drupal.org/project/checkall (D7)
Older related issues:
- #540280: Select All button for long lists of checkboxes
- #3459243: Extend core's Checkboxes Element
- #3459243: Extend core's Checkboxes Element
Steps to reproduce
Create a form
Proposed resolution
Implement a proof of concept for this functionality in contrib (#3459243: Extend core's Checkboxes Element) using the existing implementation from this module for the contrib field widget.
Remaining tasks
- Discuss
- Implement
- Review / Improve
- Write tests
- Create follow-up to add a setting to checkboxes field widget to enable / disable this functionality e.g. for entity reference checkboxes, lists, etc.
User interface changes
Additional check all / uncheck all functionality for Checkboxes, if #checkall
is enabled
API changes
New #checkall
option for Checkboxes Element
Data model changes
None, this is UI (JS) only
Release notes snippet
TBD