You are here

function geolocation_proximity_views_handler_field_distance::extra_options_form in Geolocation Proximity 7.2

Provide a form for setting options.

Overrides views_handler::extra_options_form

File

handlers/geolocation_proximity_views_handler_field_distance.inc, line 88
Definition of geolocation_proximity_views_handler_field_distance.

Class

geolocation_proximity_views_handler_field_distance
Distance field handler for views.

Code

function extra_options_form(&$form, &$form_state) {
  $filters = array(
    '' => t(' - Use own values - '),
  );
  foreach ($this->view
    ->get_items('filter') as $filter) {
    if (preg_match('/^' . $this->real_field . '/', $filter['field'])) {
      $filters[$filter['id']] = $filter['ui_name'] ? $filter['ui_name'] . " ({$filter['field']})" : $filter['field'];
    }
  }
  $form['use_filter'] = array(
    '#type' => 'select',
    '#options' => $filters,
    '#title' => t('Use filter'),
    '#default_value' => $this->options['use_filter'],
    '#description' => t('This field requires a location (latitude, longitude) to use as reference for calculating the distance. If there are filters for this same field, the location set for the given filter can be used. If not one needs to be provided.'),
  );
  $form['location'] = array(
    '#tree' => TRUE,
    '#type' => 'fieldset',
    '#title' => t('Default location'),
    '#states' => array(
      // Only show this field when the 'toggle_me' checkbox is enabled.
      'visible' => array(
        '[name="options[use_filter]"]' => array(
          'value' => '',
        ),
      ),
    ),
  );
  $form['location']['latitude'] = array(
    '#type' => 'textfield',
    '#title' => t('Latitude'),
    '#required' => TRUE,
    '#default_value' => $this->options['location']['latitude'],
    '#weight' => 1,
  );
  $form['location']['longitude'] = array(
    '#type' => 'textfield',
    '#title' => t('Longitude'),
    '#required' => TRUE,
    '#default_value' => $this->options['location']['longitude'],
    '#weight' => 2,
  );
}