public function EntityArgument::buildOptionsForm in Geolocation Field 8.2
Same name and namespace in other branches
- 8.3 src/Plugin/views/argument/EntityArgument.php \Drupal\geolocation\Plugin\views\argument\EntityArgument::buildOptionsForm()
Provide a form to edit options for this plugin.
Overrides ProximityArgument::buildOptionsForm
File
- src/
Plugin/ views/ argument/ EntityArgument.php, line 81
Class
- EntityArgument
- Argument handler for geolocation.
Namespace
Drupal\geolocation\Plugin\views\argumentCode
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
unset($form['description']);
$options = [];
foreach ($this->entityFieldManager
->getFieldMapByFieldType('geolocation') as $entity_type => $fields) {
$entity_type_definition = $this->entityTypeManager
->getDefinition($entity_type);
foreach ($fields as $field_name => $field) {
foreach ($field['bundles'] as $bundle) {
$field_definitions = $this->entityFieldManager
->getFieldDefinitions($entity_type, $bundle);
$options[$entity_type . ':' . $bundle . ':' . $field_name] = $entity_type_definition
->getLabel() . ' - ' . $entity_type_definition
->getBundleLabel() . ' - ' . $field_definitions[$field_name]
->getLabel();
}
}
}
$form['geolocation_entity_argument_source'] = [
'#type' => 'select',
'#title' => $this
->t('Geolocation Entity Argument Source'),
'#options' => $options,
'#weight' => -10,
'#default_value' => $this->options['geolocation_entity_argument_source'],
'#description' => $this
->t('Format should be in the following format: <strong>"654<=5mi"</strong> (defaults to km). Alternatively, just a valid entity ID, for use as reference location in other fields.'),
];
}