public function ProximitySort::buildOptionsForm in Geolocation Field 8
Basic options for all sort criteria
Overrides SortPluginBase::buildOptionsForm
File
- src/
Plugin/ views/ sort/ ProximitySort.php, line 31
Class
- ProximitySort
- Sort handler for geolocaiton field.
Namespace
Drupal\geolocation\Plugin\views\sortCode
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
$proximity_fields = [];
foreach ($this->view
->getHandlers('field', $this->view->current_display) as $delta => $field) {
if ($field['plugin_id'] === 'geolocation_field_proximity') {
$proximity_fields[$delta] = $field['id'];
}
}
if (empty($proximity_fields)) {
$form['proximity_field'] = [
'#markup' => $this
->t('There are no proximity fields available in this display.'),
];
}
else {
// Add the Filter selector.
$form['proximity_field'] = [
'#type' => 'select',
'#title' => $this
->t('Select field.'),
'#description' => $this
->t('Select the field to use for sorting.'),
'#options' => $proximity_fields,
'#default_value' => $this->options['proximity_field'],
];
}
// Add the Drupal\views\Plugin\views\field\Numeric settings to the form.
parent::buildOptionsForm($form, $form_state);
}