You are here

public function ClientLocation::getForm in Geolocation Field 8.2

Same name and namespace in other branches
  1. 8.3 src/Plugin/geolocation/LocationInput/ClientLocation.php \Drupal\geolocation\Plugin\geolocation\LocationInput\ClientLocation::getForm()

Get center form.

Parameters

int $center_option_id: LocationInput option ID.

array $center_option_settings: The current feature settings.

mixed $context: Context like field formatter, field widget or view.

array $default_value: Optional form values.

Return value

array Form.

Overrides LocationInputBase::getForm

File

src/Plugin/geolocation/LocationInput/ClientLocation.php, line 60

Class

ClientLocation
Location based proximity center.

Namespace

Drupal\geolocation\Plugin\geolocation\LocationInput

Code

public function getForm($center_option_id, array $center_option_settings, $context = NULL, array $default_value = NULL) {
  $form = parent::getForm($center_option_id, $center_option_settings, $context, $default_value);
  $identifier = uniqid($center_option_id);
  if (!empty($form['coordinates'])) {
    $form['coordinates']['#attributes'] = [
      'class' => [
        $identifier,
        'location-input-client-location',
      ],
    ];
    $form['coordinates']['#attached'] = [
      'library' => [
        'geolocation/location_input.client_location',
      ],
      'drupalSettings' => [
        'geolocation' => [
          'locationInput' => [
            'clientLocation' => [
              [
                'identifier' => $identifier,
                'autoSubmit' => $center_option_settings['auto_submit'],
                'hideForm' => $center_option_settings['hide_form'],
              ],
            ],
          ],
        ],
      ],
    ];
  }
  return $form;
}