This module provides an extension to the builtin checkboxes element that allows developers add "check all" / "toggle" / "uncheck all" actions to them. This is specially useful for checkboxes that have a lot of elements.

Please note that Drupal 6 already has this feature available, but only for checkboxes rendered in tables, such as those used in Administration -> Content management -> Content. Checkboxes rendered elsewhere do not have this feature.

You may need to install this module when required/recommended by another contributed module, and/or you may wish to use it to enhance your own custom modules.

  • For Site Administrators - New option for checkboxes implemented by CCK Widgets

    If you use checkboxes implemented by CCK optionwidgets, node reference, user reference or content taxonomy options, then a new option in the field settings form is available to enable the Checkall feature for those widgets.

  • For Developers - Simple Usage

    To attach the checkall behavior to checkboxes elements, all you need to do is add the '#checkall' property to them. You can do so for your own forms, or you can implement hook_alter_form() to add this property to existing forms. Example:

    <?php
    $form
    ['foobar'] = array(
     
    '#type' => 'checkboxes',
     
    '#options' => $options,
     
    '#default_value' => $default_value,
     
    '#checkall' => TRUE// <--- this is it ;-)
    );
    ?>
  • For Developers - Advanced Usage

    The checkall behavior can also be attached to checkboxes in tables, just like Drupal's tableselect.js behavior, but checkall supports more than one column of checkboxes. In this case, the element attribute should specify a unique CSS class for each group of checkboxes.

    <?php
    $form
    ['foobar'] = array(
     
    '#type' => 'checkboxes',
     
    '#options' => $options,
     
    '#default_value' => $default_value,
     
    '#checkall' => 'unique-class-for-each-checkboxes-column'// <--- this is it ;-)
    );
    ?>

    And then, in your theme function where you render the table, you should assign the unique CSS classes to the table headers that correspond to the proper checkboxes column.

    The checkall module provides a couple of example modules that better describe how it all works.

  • CREDITS

    The first version of the module was written by rszrama and it is still available from the Drupal 5 branch of the project. Many thanks to him for letting me use his project for the implementation of this checkboxes addon for Drupal 6. For further information about the Drupal 5 version of this module, please see its own README.txt

Project Information

Downloads