I'm currently using a computed field to assign a "Decade" value to a content type. I have a view set up with an exposed filter whereby a user can enter a decade they'd like to search against. Although the default output is a text field, I've used hook_form_alter to modify the field into a dropdown box with predefined values using this code:
function decadeselect_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == "views_exposed_form" && $form['#id'] == "views-exposed-form-exposed-filter-search-page-1") {
if (empty($form_state['view']->exposed_input['field_collection_item_decade_value'])) {
$form_state['input']['field_collection_item_decade_value'] = $form['field_collection_item_decade_value']['#options']['All'];;
}
$form['field_collection_item_decade_value']['#type'] = "select";
$form['field_collection_item_decade_value']['#size'] = null;
$form['field_collection_item_decade_value']['#default_value'] = $form['field_collection_item_decade_value']['#options']['All'];
$form['field_collection_item_decade_value']['#options'] = array(
'All' => t('<Any>'),
'2000s' => t('2000s'),
'1990s' => t('1990s'),
'1980s' => t('1980s'),
'1970s' => t('1970s'),
'1960s' => t('1960s'),
'1950s' => t('1950s'),
'1940s' => t('1940s'),
'Prior to 1940' => t('Prior to 1940')
);
}
}
This is working fine, but ideally, I would like the user to be able to select multiple values at once using checkboxes. My issue doesn't lie with formatting my options as checkboxes (I've figured that out), but with filtering against the computed field using multiple values. By nature this is a textfield, so I can search against multiple items by modifying the URL a bit: field_collection_item_decade_value=2000s+1990s but my problem is getting to that point. I was thinking along the lines of a custom submit function, although I have no experience implementing that. Any suggestions?
Comments
Comment #1
nikolay shapovalov commentedI have the same problem. Did you find any solution&
Comment #2
dqdDue to the Drupal core life cycle policy and security support advisery, Drupal 6 is no longer supported. So issues for Drupal 6 cannot be longer maintained. The project maintainer has asked for closing all D6 issues to clean up the issue queue. Feel free to reopen the issue if required or set it to "needs to be ported" and latest D8 dev version, if the issue discusses a still missing feature which can be implemented in the D8 version.
Comment #3
dqdComment #4
colanActually, this is a duplicate of #908544: Change views exposed filter from textfield to dropdown list.