How to provide ‘Select all checkboxes’ option in Drupal 7

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:

https://www.drupal.org/project/checkall

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.

Step 1:

First install and activate the module.
checkall-modules

Step 2:

Then ‘Add a new field’ in the Article content type as shown below:

article-drupal

Step 3:

Add some values in the list as shown below:

checkbox-step2

Step 4:

Finally Enable the below option and in the field settings select ‘Unlimted’:

enable-checkall

That’s it you have successfully enabled the checkall option for the check-boxes.

Let’s see how it displays in the article section

checkall-in-article

That’s it friends, kindly share this post if you liked it.

About the Author

agurchand

Software Engineer, Blogger etc., Visit my Youtube channel - <a href="http://www.youtube.com/agurchand">Click Here</a>

1 thought on “How to provide ‘Select all checkboxes’ option in Drupal 7

    • Author gravatar

      Good tutorial but the module has really bad support. A few known bugs and no solutions for them.
      For example,

      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.

Leave a Reply

Your email address will not be published. Required fields are marked *