public function GeocodeFormatterBase::settingsForm in Geocoder 8.3
Same name and namespace in other branches
- 8.2 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 185
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);
$providers = !empty($this
->getSetting('providers')) ? $this
->getSetting('providers') : [];
// Attach Geofield Map Library.
$element['#attached']['library'] = [
'geocoder/general',
];
// Get the enabled/selected providers.
$enabled_providers = [];
foreach ($providers as $provider_id => $provider_settings) {
if ($provider_settings['checked']) {
$enabled_providers[] = $provider_id;
}
}
// Generates the Draggable Table of Selectable Geocoder providers.
$element['providers'] = $this->providerPluginManager
->providersPluginsTableList($enabled_providers);
// Set a validation for the providers selection.
$element['providers']['#element_validate'] = [
[
get_class($this),
'validateProvidersSettingsForm',
],
];
$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;
}