You are here

public function GooglePlacesAPI::getOptionsForm in Geolocation Field 8

Return additional options form.

Return value

array Options form.

Overrides GeocoderBase::getOptionsForm

File

modules/geolocation_google_places_api/src/Plugin/geolocation/Geocoder/GooglePlacesAPI.php, line 29

Class

GooglePlacesAPI
Provides the Google Places API.

Namespace

Drupal\geolocation_google_places_api\Plugin\geolocation\Geocoder

Code

public function getOptionsForm() {
  $settings = [
    'route' => '',
    'locality' => '',
    'administrativeArea' => '',
    'postalCode' => '',
    'country' => '',
  ];
  if (isset($this->configuration['component_restrictions'])) {
    $settings = array_replace($settings, $this->configuration['component_restrictions']);
  }
  return [
    'description' => [
      '#type' => 'html_tag',
      '#tag' => 'span',
      '#value' => $this
        ->getPluginDefinition()['description'],
    ],
    'component_restrictions' => [
      '#type' => 'fieldset',
      '#title' => $this
        ->t('Component Restrictions'),
      'route' => [
        '#type' => 'textfield',
        '#default_value' => $settings['route'],
        '#title' => $this
          ->t('Route'),
        '#size' => 15,
      ],
      'locality' => [
        '#type' => 'textfield',
        '#default_value' => $settings['locality'],
        '#title' => $this
          ->t('Locality'),
        '#size' => 15,
      ],
      'administrativeArea' => [
        '#type' => 'textfield',
        '#default_value' => $settings['administrativeArea'],
        '#title' => $this
          ->t('Administrative Area'),
        '#size' => 15,
      ],
      'postalCode' => [
        '#type' => 'textfield',
        '#default_value' => $settings['postalCode'],
        '#title' => $this
          ->t('Postal code'),
        '#size' => 5,
      ],
      'country' => [
        '#type' => 'textfield',
        '#default_value' => $settings['country'],
        '#title' => $this
          ->t('Country'),
        '#size' => 5,
      ],
    ],
  ];
}