public function GeofieldProximityField::buildOptionsForm in Geofield 8
Default options form that provides the label widget that all fields should have.
Overrides NumericField::buildOptionsForm
File
- src/
Plugin/ views/ field/ GeofieldProximityField.php, line 84
Class
- GeofieldProximityField
- Field handler to render a Geofield proximity in Views.
Namespace
Drupal\geofield\Plugin\views\fieldCode
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
$context = $this->pluginDefinition['plugin_type'];
$user_input = $form_state
->getUserInput();
$source_plugin_id = isset($user_input['options']['source']) ? $user_input['options']['source'] : $this->options['source'];
$source_plugin_configuration = isset($user_input['options']['source_configuration']) ? $user_input['options']['source_configuration'] : $this->options['source_configuration'];
$this->proximitySourceManager
->buildCommonFormElements($form, $form_state, $context);
$form['units']['#default_value'] = $this->options['units'];
$form['source']['#default_value'] = $this->options['source'];
try {
$this->sourcePlugin = $this->proximitySourceManager
->createInstance($source_plugin_id, $source_plugin_configuration);
$this->sourcePlugin
->setViewHandler($this);
$form['source_configuration']['origin_description'] = [
'#markup' => $this->sourcePlugin
->getPluginDefinition()['description'],
'#weight' => -10,
];
$this->sourcePlugin
->buildOptionsForm($form['source_configuration'], $form_state, [
'source_configuration',
]);
} catch (\Exception $e) {
watchdog_exception('geofield', $e);
}
parent::buildOptionsForm($form, $form_state);
}