You are here

public function Yandex::getSettingsForm in Geolocation Field 8.3

Same name and namespace in other branches
  1. 8.2 modules/geolocation_yandex/src/Plugin/geolocation/MapProvider/Yandex.php \Drupal\geolocation_yandex\Plugin\geolocation\MapProvider\Yandex::getSettingsForm()

Provide a generic map settings form array.

Parameters

array $settings: The current map settings.

array $parents: Form parents.

Return value

array A form array to be integrated in whatever.

Overrides MapProviderBase::getSettingsForm

File

modules/geolocation_yandex/src/Plugin/geolocation/MapProvider/Yandex.php, line 69

Class

Yandex
Provides Yandex Maps API.

Namespace

Drupal\geolocation_yandex\Plugin\geolocation\MapProvider

Code

public function getSettingsForm(array $settings, array $parents = []) {
  $settings += self::getDefaultSettings();
  if ($parents) {
    $parents_string = implode('][', $parents);
  }
  else {
    $parents_string = NULL;
  }
  $form = parent::getSettingsForm($settings, $parents);
  $form['height'] = [
    '#group' => $parents_string,
    '#type' => 'textfield',
    '#title' => $this
      ->t('Height'),
    '#description' => $this
      ->t('Enter the dimensions and the measurement units. E.g. 200px or 100%.'),
    '#size' => 4,
    '#default_value' => $settings['height'],
  ];
  $form['width'] = [
    '#group' => $parents_string,
    '#type' => 'textfield',
    '#title' => $this
      ->t('Width'),
    '#description' => $this
      ->t('Enter the dimensions and the measurement units. E.g. 200px or 100%.'),
    '#size' => 4,
    '#default_value' => $settings['width'],
  ];
  $form['zoom'] = [
    '#group' => $parents_string,
    '#type' => 'select',
    '#title' => $this
      ->t('Zoom level'),
    '#options' => range(0, 20),
    '#description' => $this
      ->t('The initial resolution at which to display the map, where zoom 0 corresponds to a map of the Earth fully zoomed out, and higher zoom levels zoom in at a higher resolution.'),
    '#default_value' => $settings['zoom'],
    '#process' => [
      [
        '\\Drupal\\Core\\Render\\Element\\RenderElement',
        'processGroup',
      ],
      [
        '\\Drupal\\Core\\Render\\Element\\Select',
        'processSelect',
      ],
    ],
    '#pre_render' => [
      [
        '\\Drupal\\Core\\Render\\Element\\RenderElement',
        'preRenderGroup',
      ],
    ],
  ];
  return $form;
}