You are here

public function SearchApiViewsHandlerFilterLocation::options_form in Search API Location 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

search_api_location_views/handler_filter_location.inc, line 28
Provides the views handler for location fields.

Class

SearchApiViewsHandlerFilterLocation
Handler class for a Views location filter.

Code

public function options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);
  $form['plugin'] = array(
    '#type' => 'select',
    '#title' => t('Input method'),
    '#description' => t('Select the method to use for parsing locations entered by the user.'),
    '#options' => search_api_location_get_input_plugin_options(),
    '#default_value' => $this->options['plugin'],
    '#required' => TRUE,
  );
  foreach (search_api_location_get_input_plugins() as $id => $plugin) {
    $form["plugin-{$id}"] = array(
      '#type' => 'fieldset',
      '#title' => t('Input method settings'),
      '#description' => $plugin['description'],
      '#tree' => TRUE,
      '#dependency' => array(
        'edit-options-plugin' => array(
          $id,
        ),
      ),
    );
    if (!empty($plugin['form callback'])) {
      $plugin_form = $plugin['form callback']($form_state, $this->options["plugin-{$id}"]);
      if ($plugin_form) {
        $form["plugin-{$id}"] += $plugin_form;
      }
    }
  }
  $form['radius_type'] = array(
    '#type' => 'select',
    '#title' => t('Type of distance input'),
    '#description' => t('Select the type of input element for the distance option.'),
    '#options' => array(
      'select' => t('Select'),
      'textfield' => t('Text field'),
    ),
    '#default_value' => $this->options['radius_type'],
    '#dependency' => array(
      'edit-options-expose-use-operator' => array(
        1,
      ),
    ),
  );
  $form['radius_options'] = array(
    '#type' => 'textarea',
    '#title' => t('Distance options'),
    '#description' => t('Add one line per option for “Range” you want to provide. The first part of each line is the distance in kilometres, everything after the first space is the label. "-" as the distance ignores the location for filtering, but will still use it for facets, sorts and distance calculation. Skipping the distance altogether (i.e., starting the line with a space) will provide an option for ignoring the entered location completely.'),
    '#default_value' => $this->options['radius_options'],
    '#dependency' => array(
      'edit-options-radius-type' => array(
        'select',
      ),
    ),
  );
  $form['radius_units'] = array(
    '#type' => 'textfield',
    '#title' => t('Distance conversion factor'),
    '#description' => t('Enter the conversion factor from the expected unit of the user input to kilometers. E.g., miles would have a factor of 1.60935.'),
    '#default_value' => $this->options['radius_units'],
    '#dependency' => array(
      'edit-options-radius-type' => array(
        'textfield',
      ),
    ),
  );
}