public function ProximityFilter::valueForm in Geolocation Field 8.2
Same name and namespace in other branches
- 8.3 src/Plugin/views/filter/ProximityFilter.php \Drupal\geolocation\Plugin\views\filter\ProximityFilter::valueForm()
Provide a simple textfield for equality
Overrides NumericFilter::valueForm
File
- src/
Plugin/ views/ filter/ ProximityFilter.php, line 111
Class
- ProximityFilter
- Filter handler for search keywords.
Namespace
Drupal\geolocation\Plugin\views\filterCode
public function valueForm(&$form, FormStateInterface $form_state) {
parent::valueForm($form, $form_state);
if (!isset($form['value']['value'])) {
$form['value'] = array_replace($form['value'], [
'#type' => 'number',
'#min' => 0,
'#step' => 0.1,
'#title' => $this
->t('Distance'),
'#description' => $this
->t('Distance in %unit', [
'%unit' => $this->options['unit'] === 'km' ? $this
->t('Kilometers') : $this
->t('Miles'),
]),
'#default_value' => self::convertDistance($form['value']['#default_value'], $this->options['unit'], TRUE),
]);
}
else {
$form['value']['value'] = array_replace($form['value']['value'], [
'#type' => 'number',
'#min' => 0,
'#step' => 0.1,
'#title' => $this
->t('Distance'),
'#description' => $this
->t('Distance in %unit', [
'%unit' => $this->options['unit'] === 'km' ? $this
->t('Kilometers') : $this
->t('Miles'),
]),
'#default_value' => self::convertDistance($form['value']['value']['#default_value'], $this->options['unit'], TRUE),
]);
}
$center_form = $this->locationInputManager
->getForm($this->options['location_input'], $this, empty($this->value['center']) ? NULL : $this->value['center']);
if (!empty($center_form)) {
$form['center'] = $center_form;
}
}