Does anyone have an idea how to display checkboxes instead of multiselect fields in the exposed filters of a view?

Comments

tomsun’s picture

You could check out this discussion: http://groups.drupal.org/node/5207

Or, a quick alternative If you want to turn ALL select fields of ALL views filters into checkboxes;
Create a module called 'viewsfiltercheckboxes.module' or anything you like, containing:


/**
 * Implementation of hook_form_alter().
 */
function viewsfiltercheckboxes_form_alter($form_id, &$form) {
  
  if ($form_id == 'views_filters') {
    if(!empty($form)) {
      foreach ($form as $id => $field) {
        if ($form[$id]['#type'] == 'select') {
          $form[$id]['#type'] = 'checkboxes';
        }
      }
    }
  }
}

You also need an info file 'viewsfiltercheckboxes.info'

name = Views Filter Checkboxes
dependencies = views
package = Views

Put these files in a subdirectory of your modules directory and activate the module.

derjochenmeyer’s picture

Its what i was looking for!

----------------------
okay.cool