You are here

public function location_handler_filter_location_province::value_form in Location 7.3

Same name and namespace in other branches
  1. 6.3 handlers/location_handler_filter_location_province.inc \location_handler_filter_location_province::value_form()
  2. 7.5 handlers/location_handler_filter_location_province.inc \location_handler_filter_location_province::value_form()
  3. 7.4 handlers/location_handler_filter_location_province.inc \location_handler_filter_location_province::value_form()

Provide a simple textfield for equality.

Overrides views_handler_filter::value_form

File

handlers/location_handler_filter_location_province.inc, line 54
Filter on province.

Class

location_handler_filter_location_province

Code

public function value_form(&$form, &$form_state) {
  $country = $this
    ->grovel_country();
  $ac = $country;
  if (is_array($ac)) {
    $ac = implode(',', $ac);
  }
  if ($this->options['type'] == 'textfield') {
    drupal_add_js(drupal_get_path('module', 'location') . '/location_autocomplete.js');
    $form['value'] = array(
      '#type' => 'textfield',
      '#title' => t('State/Province'),
      '#autocomplete_path' => 'location/autocomplete/' . $ac,
      '#default_value' => $this->value,
      '#size' => 64,
      '#maxlength' => 64,
      // Used by province autocompletion js.
      '#attributes' => array(
        'class' => array(
          'location_auto_province',
        ),
      ),
      '#multiple' => TRUE,
    );

    // Let location_autocomplete.js find the correct fields to attach.
    if ($this->location_country_identifier) {
      $form['value']['#attributes']['class'][] = 'location_auto_join_' . $this->location_country_identifier;
    }
  }
  else {
    if ($this->options['type'] == 'select') {
      $provinces = location_get_provinces($ac);
      $form['value'] = array(
        '#type' => 'select',
        '#title' => t('State/Province'),
        '#options' => $provinces,
        '#default_value' => -1,
        '#multiple' => isset($this->options['expose']['multiple']) ? $this->options['expose']['multiple'] : FALSE,
      );
    }
  }
}