public function GeocodeFormatterBase::settingsForm in Geocoder 8.2
Same name and namespace in other branches
- 8.3 modules/geocoder_field/src/Plugin/Field/GeocodeFormatterBase.php \Drupal\geocoder_field\Plugin\Field\GeocodeFormatterBase::settingsForm()
Returns a form to configure settings for the formatter.
Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the formatter. The field_ui module takes care of handling submitted form values.
Parameters
array $form: The form where the settings form is being included in.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form elements for the formatter settings.
Overrides FormatterBase::settingsForm
2 calls to GeocodeFormatterBase::settingsForm()
- FileGeocodeFormatter::settingsForm in modules/
geocoder_field/ src/ Plugin/ Field/ FieldFormatter/ FileGeocodeFormatter.php - Returns a form to configure settings for the formatter.
- GeocodeFormatter::settingsForm in modules/
geocoder_field/ src/ Plugin/ Field/ FieldFormatter/ GeocodeFormatter.php - Returns a form to configure settings for the formatter.
2 methods override GeocodeFormatterBase::settingsForm()
- FileGeocodeFormatter::settingsForm in modules/
geocoder_field/ src/ Plugin/ Field/ FieldFormatter/ FileGeocodeFormatter.php - Returns a form to configure settings for the formatter.
- GeocodeFormatter::settingsForm in modules/
geocoder_field/ src/ Plugin/ Field/ FieldFormatter/ GeocodeFormatter.php - Returns a form to configure settings for the formatter.
File
- modules/
geocoder_field/ src/ Plugin/ Field/ GeocodeFormatterBase.php, line 154
Class
- GeocodeFormatterBase
- Base Plugin implementation of the Geocode formatter.
Namespace
Drupal\geocoder_field\Plugin\FieldCode
public function settingsForm(array $form, FormStateInterface $form_state) {
$element = parent::settingsForm($form, $form_state);
// Attach Geofield Map Library.
$element['#attached']['library'] = [
'geocoder/general',
];
// Get the enabled/selected plugins.
$enabled_plugins = [];
foreach ($this
->getSetting('plugins') as $plugin_id => $plugin) {
if ($plugin['checked']) {
$enabled_plugins[] = $plugin_id;
}
}
// Generates the Draggable Table of Selectable Geocoder Plugins.
$element['plugins'] = $this->providerPluginManager
->providersPluginsTableList($enabled_plugins);
// Set a validation for the plugins selection.
$element['plugins']['#element_validate'] = [
[
get_class($this),
'validatePluginsSettingsForm',
],
];
$element['dumper'] = [
'#type' => 'select',
'#weight' => 25,
'#title' => 'Output format',
'#default_value' => $this
->getSetting('dumper'),
'#options' => $this->dumperPluginManager
->getPluginsAsOptions(),
'#description' => t('Set the output format of the value. Ex, for a geofield, the format must be set to WKT.'),
];
return $element;
}