You are here

protected function GeofieldRectBoundaryFilter::valueForm in Geofield 8

Options form subform for setting options.

This should be overridden by all child classes and it must define $form['value']

Overrides FilterPluginBase::valueForm

See also

buildOptionsForm()

File

src/Plugin/views/filter/GeofieldRectBoundaryFilter.php, line 63

Class

GeofieldRectBoundaryFilter
Filter handler for search keywords.

Namespace

Drupal\geofield\Plugin\views\filter

Code

protected function valueForm(&$form, FormStateInterface $form_state) {
  parent::valueForm($form, $form_state);
  $form['value']['#tree'] = TRUE;
  $form['value']['#prefix'] = '<div id="geofield-boundary-filter">';
  $form['value']['#suffix'] = '</div>';
  $form['value']['group'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('Rectangle Boundaries'),
    '#open' => TRUE,
  ];
  $value_element =& $form['value'];

  // Add the Latitude and Longitude elements.
  $value_element['group']['lat_north_east'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('NE Latitude'),
    '#default_value' => !empty($this->value['group']['lat_north_east']) ? $this->value['group']['lat_north_east'] : '',
    '#weight' => 10,
    '#size' => 12,
  ];
  $value_element['group']['lng_north_east'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('NE Longitude'),
    '#default_value' => !empty($this->value['group']['lng_north_east']) ? $this->value['group']['lng_north_east'] : '',
    '#weight' => 20,
    '#size' => 12,
  ];
  $value_element['group']['lat_south_west'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('SW Latitude'),
    '#default_value' => !empty($this->value['group']['lat_south_west']) ? $this->value['group']['lat_south_west'] : '',
    '#weight' => 30,
    '#size' => 12,
  ];
  $value_element['group']['lng_south_west'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('SW Longitude'),
    '#default_value' => !empty($this->value['group']['lng_south_west']) ? $this->value['group']['lng_south_west'] : '',
    '#weight' => 40,
    '#size' => 12,
  ];
}