When I set up an exposed filter with the "Limit list to selected items" option enabled, and select a subset of items in the "Options" list, when the view is presented, non of the selected items are selected by default.

If I turn off the "Limit..." option, then all items (checked and not) are shown, with the checked items selected by default.

Sorry if I'm not describing it more clearly, but I would like a limited list displayed, with all of its items selected by default.


BTW - I'm using Better Exposed Filters to display the selection items as checkboxes and the exposed form is shown in a block.

Thanks. Bill


If you want to define a default value for a limited list of items in a Views exposed filter, you can achieve it by altering the exposed filter in a custom module:

function mymodule_form_views_exposed_form_alter(&$form, &$form_state) {
  $filter_field_id = 'my_filter_identifier';
  if (isset($form[$filter_field_id])) {
    $options = array();
    $options['First option value']  = 'First option label';
    $options['Second option value'] = 'Second option label';
    $form[$filter_field_id]['#type'] = 'select';
    $form[$filter_field_id]['#options'] = $options;
    $form[$filter_field_id]['#default_value'] = 'First option value';

In order to make it to work, you need to uncheck the "Limit list to selected" option in the Views exposed filter. Of course, you also need to know the real values of your list items.

If your Views default value includes multiple options from the list, and you do not want to allow the user to select multiple options at once, you will also need to add a new filter blocking the other undesired options.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.