You are here

public function Dummy::formAttachGeocoder in Geolocation Field 8

Same name and namespace in other branches
  1. 8.3 tests/modules/geolocation_dummy_geocoder/src/Plugin/geolocation/Geocoder/Dummy.php \Drupal\geolocation_dummy_geocoder\Plugin\geolocation\Geocoder\Dummy::formAttachGeocoder()
  2. 8.2 tests/modules/geolocation_dummy_geocoder/src/Plugin/geolocation/Geocoder/Dummy.php \Drupal\geolocation_dummy_geocoder\Plugin\geolocation\Geocoder\Dummy::formAttachGeocoder()

Attach geocoding logic to input element.

Parameters

array $render_array: Form containing the input element.

string $element_name: Name of the input element.

Return value

array|null Updated form element or NULL.

Overrides GeocoderBase::formAttachGeocoder

File

tests/modules/geolocation_dummy_geocoder/src/Plugin/geolocation/Geocoder/Dummy.php, line 38

Class

Dummy
Provides the Google Geocoding API.

Namespace

Drupal\geolocation_dummy_geocoder\Plugin\geolocation\Geocoder

Code

public function formAttachGeocoder(array &$render_array, $element_name) {
  $render_array['geolocation_geocoder_dummy'] = [
    '#type' => 'textfield',
    '#description' => $this
      ->t('Enter one of the statically defined targets. See geolocation/Geocoder/Dummy.php.'),
    '#attributes' => [
      'class' => [
        'form-autocomplete',
        'geolocation-views-filter-geocoder',
        'geolocation-geocoder-dummy',
      ],
      'data-source-identifier' => $element_name,
    ],
  ];
  $render_array = array_merge_recursive($render_array, [
    '#attached' => [
      'library' => [
        0 => 'geolocation_dummy_geocoder/geocoder',
      ],
    ],
  ]);
  $render_array['geolocation_geocoder_dummy_state'] = [
    '#type' => 'hidden',
    '#default_value' => 1,
    '#attributes' => [
      'class' => [
        'geolocation-geocoder-dummy-state',
      ],
      'data-source-identifier' => $element_name,
    ],
  ];
}