You are here

public function GeolocationMapWidgetBase::settingsForm in Geolocation Field 8.3

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldWidget/GeolocationMapWidgetBase.php \Drupal\geolocation\Plugin\Field\FieldWidget\GeolocationMapWidgetBase::settingsForm()

Returns a form to configure settings for the widget.

Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the widget. 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 definition for the widget settings.

Overrides WidgetBase::settingsForm

File

src/Plugin/Field/FieldWidget/GeolocationMapWidgetBase.php, line 158

Class

GeolocationMapWidgetBase
Map widget base.

Namespace

Drupal\geolocation\Plugin\Field\FieldWidget

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $settings = $this
    ->getSettings();
  $element = [];
  $element['centre'] = $this->mapCenterManager
    ->getCenterOptionsForm((array) $settings['centre'], [
    'widget' => $this,
  ]);
  $element['auto_client_location_marker'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Automatically set marker to client location if available.'),
    '#default_value' => $settings['auto_client_location_marker'],
  ];
  $element['allow_override_map_settings'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Allow override the map settings when create/edit an content.'),
    '#default_value' => $settings['allow_override_map_settings'],
  ];
  $element['hide_textfield_form'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Hide textfields.'),
    '#default_value' => $settings['hide_textfield_form'],
  ];
  if ($this->mapProvider) {
    $element[static::$mapProviderSettingsFormId] = $this->mapProvider
      ->getSettingsForm($settings[static::$mapProviderSettingsFormId], [
      'fields',
      $this->fieldDefinition
        ->getName(),
      'settings_edit_form',
      'settings',
      static::$mapProviderSettingsFormId,
    ]);
  }
  return $element;
}