You are here

public function ProximityField::buildOptionsForm in Geolocation Field 8.3

Same name and namespace in other branches
  1. 8 src/Plugin/views/field/ProximityField.php \Drupal\geolocation\Plugin\views\field\ProximityField::buildOptionsForm()
  2. 8.2 src/Plugin/views/field/ProximityField.php \Drupal\geolocation\Plugin\views\field\ProximityField::buildOptionsForm()

Default options form that provides the label widget that all fields should have.

Overrides NumericField::buildOptionsForm

1 call to ProximityField::buildOptionsForm()
ProximityFormField::buildOptionsForm in src/Plugin/views/field/ProximityFormField.php
Default options form that provides the label widget that all fields should have.
1 method overrides ProximityField::buildOptionsForm()
ProximityFormField::buildOptionsForm in src/Plugin/views/field/ProximityFormField.php
Default options form that provides the label widget that all fields should have.

File

src/Plugin/views/field/ProximityField.php, line 76

Class

ProximityField
Field handler for geolocation field.

Namespace

Drupal\geolocation\Plugin\views\field

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);
  $form['center'] = $this->locationManager
    ->getLocationOptionsForm($this->options['center'], $this);
  $form['display_unit'] = [
    '#title' => $this
      ->t('Distance unit'),
    '#description' => $this
      ->t('Values internally are always treated as kilometers. This setting converts values accordingly.'),
    '#type' => 'select',
    '#weight' => 5,
    '#default_value' => $this->options['display_unit'],
    '#options' => [
      'km' => $this
        ->t('Kilometer'),
      'mi' => $this
        ->t('Miles'),
      'nm' => $this
        ->t('Nautical Miles'),
      'm' => $this
        ->t('Meter'),
      'ly' => $this
        ->t('Light-years'),
    ],
  ];
}