You are here

function geofield_handler_filter::options_form in Geofield 7.2

Provide the basic form which calls through to subforms.

If overridden, it is best to call through to the parent, or to at least make sure all of the functions in this form are called.

Overrides views_handler_filter::options_form

File

views/handlers/geofield_handler_filter.inc, line 118
Distance filter implementation.

Class

geofield_handler_filter
@file Distance filter implementation.

Code

function options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);
  $form['source'] = array(
    '#type' => 'select',
    '#title' => t('Source of Origin Point'),
    '#description' => t('How do you want to enter your origin point?'),
    '#options' => array(),
    '#attached' => array(
      'js' => array(
        drupal_get_path('module', 'geofield') . '/js/viewsProximityValue.js',
      ),
    ),
    '#default_value' => $this->options['source'],
  );
  $form['source_change'] = array(
    '#type' => 'submit',
    '#value' => 'Change Source Widget',
    '#submit' => array(
      'geofield_views_ui_change_proximity_widget',
    ),
  );
  $proximityHandlers = module_invoke_all('proximity_views_handlers');
  foreach ($proximityHandlers as $key => $handler) {

    // Manually skip 'Exposed Filter', since it wouldn't make any sense in this context.
    if ($key != 'exposed_geofield_filter') {
      $form['source']['#options'][$key] = $handler['name'];
      if (class_exists($handler['class'])) {
        $proximityPlugin = new $handler['class']();
        $proximityPlugin
          ->options_form($form, $form_state, $this);
      }
    }
  }

  // Look for any top-level item with a #proximity_plugin_value_element set. If found, it doesn't
  // belong in this particular field.
  foreach ($form as $key => $form_item) {
    if (isset($form_item['#proximity_plugin_value_element']) && $form_item['#proximity_plugin_value_element'] == TRUE) {
      unset($form[$key]);
    }
  }
}