Drupal has provided Form API’s to create checkboxes easily unfortunately it didn’t offer a select all / deselect all checkboxes option.
But no worries, there are plenty of contributed modules are present in Drupal site which will help us to extend the Drupal functionality. One of the module which we are going to use it called ‘checkall’ module. Please click the below link to see the module:
The above module gives us “check all” / “toggle” / “uncheck all” actions to the checkbox group. Let’s see how to activate this in a form.
First install and activate the module.
Then ‘Add a new field’ in the Article content type as shown below:
Add some values in the list as shown below:
Finally Enable the below option and in the field settings select ‘Unlimted’:
That’s it you have successfully enabled the checkall option for the check-boxes.
Let’s see how it displays in the article section
That’s it friends, kindly share this post if you liked it.
One thought on “How to provide ‘Select all checkboxes’ option in Drupal 7”
Good tutorial but the module has really bad support. A few known bugs and no solutions for them.
If you have more than one checkall added on a single content type it gives you problems if you want to enable one and disable another or if you want to show “toggle” on one and not another.
Also the hook_form_alter also has problems if you have more than one field using it on the same form. Meaning if you try to make one FALSE, it will not do it since it reads the True from the others. Basically it has problems and little to no support or maintenance.
Use it if you will only have one multicheckbox per node. If you require more than one, be ready to face bugs.