You are here

function getlocations_fields_handler_filter_country::value_form in Get Locations 7

Same name and namespace in other branches
  1. 7.2 modules/getlocations_fields/handlers/getlocations_fields_handler_filter_country.inc \getlocations_fields_handler_filter_country::value_form()

Provide widgets for filtering by country.

Overrides views_handler_filter_in_operator::value_form

File

modules/getlocations_fields/handlers/getlocations_fields_handler_filter_country.inc, line 28
getlocations_fields_handler_filter_country.inc @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Class

getlocations_fields_handler_filter_country
@file getlocations_fields_handler_filter_country.inc @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Code

function value_form(&$form, &$form_state) {
  $this
    ->get_value_options();
  $options = $this->value_options;
  $default_value = (array) $this->value;
  if (!empty($form_state['exposed'])) {
    $identifier = $this->options['expose']['identifier'];
    if (empty($this->options['expose']['use_operator']) || empty($this->options['expose']['operator_id'])) {

      // exposed and locked.
      $which = in_array($this->operator, $this
        ->operator_values(1)) ? 'value' : 'none';
    }
    else {
      $source = 'edit-' . drupal_html_id($this->options['expose']['operator_id']);
    }
    if (!empty($this->options['expose']['reduce'])) {
      $options = $this
        ->reduce_value_options();
      if (!empty($this->options['expose']['multiple']) && empty($this->options['expose']['required'])) {
        $default_value = array();
      }
    }
    if (empty($this->options['expose']['multiple'])) {
      if (empty($this->options['expose']['required']) && (empty($default_value) || !empty($this->options['expose']['reduce']))) {
        $default_value = 'All';
      }
      elseif (empty($default_value)) {
        $keys = array_keys($options);
        $default_value = array_shift($keys);
      }
      else {
        $copy = $default_value;
        $default_value = array_shift($copy);
      }
    }
  }
  $form['value'] = array(
    '#type' => 'select',
    '#title' => t('Country'),
    '#default_value' => $default_value,
    '#options' => $options,
    '#multiple' => TRUE,
  );
}