1 views_handler_filter.inc views_handler_filter::exposed_translate(&$form, $type)

Make some translations to a form item to make it more suitable to exposing.

File

core/modules/views/handlers/views_handler_filter.inc, line 1076
@todo.

Class

views_handler_filter
Base class for filters.

Code

function exposed_translate(&$form, $type) {
  if (!isset($form['#type'])) {
    return;
  }

  if ($form['#type'] == 'radios') {
    $form['#type'] = 'select';
  }
  // Checkboxes don't work so well in exposed forms due to GET conversions.
  if ($form['#type'] == 'checkboxes') {
    if (empty($form['#no_convert']) || empty($this->options['expose']['multiple'])) {
      $form['#type'] = 'select';
    }
    if (!empty($this->options['expose']['multiple'])) {
      $form['#multiple'] = TRUE;
    }
  }
  if (empty($this->options['expose']['multiple']) && isset($form['#multiple'])) {
    unset($form['#multiple']);
    $form['#size'] = NULL;
  }

  // Cleanup in case the translated element's (radios or checkboxes) display value contains html.
  if ($form['#type'] == 'select') {
    $this->prepare_filter_select_options($form['#options']);
  }

  if ($type == 'value' && empty($this->always_required) && empty($this->options['expose']['required']) && $form['#type'] == 'select' && empty($form['#multiple'])) {
    $any_label = config_get('views.settings', 'exposed_filter_any_label') == 'old_any' ? t('<Any>') : t('- Any -');
    $form['#options'] = array('All' => $any_label) + $form['#options'];
    $form['#default_value'] = 'All';
  }

  if (!empty($this->options['expose']['required'])) {
    $form['#required'] = TRUE;
  }
}