You are here

public function TileWMS::optionsFormSubmit in Openlayers 7.3

Submit callback for the options form.

Parameters

array $form: The form array.

array $form_state: The form_state array by reference.

Overrides Base::optionsFormSubmit

File

src/Plugin/Source/TileWMS/TileWMS.php, line 45
Source: TileWMS.

Class

TileWMS
Class TileWMS.

Namespace

Drupal\openlayers\Plugin\Source\TileWMS

Code

public function optionsFormSubmit(array $form, array &$form_state) {

  // If an options array is not set, create it.
  if (!isset($form_state['item']->options)) {
    $form_state['item']->options = array();
  }

  // If the URL is blank, unset it in the options.
  if ($form_state['values']['options']['url'] == '') {
    unset($form_state['item']->options['url']);
  }

  // Create a parameters array if it doesn't already exist.
  if (!isset($form_state['item']->options['params'])) {
    $form_state['item']->options['params'] = array();
  }

  // Copy parameters into the params array.
  $param_keys = array(
    'wms_layers' => 'LAYERS',
    'version' => 'VERSION',
  );
  foreach ($param_keys as $key => $param) {
    if (!empty($form_state['values']['options'][$key])) {
      $form_state['item']->options['params'][$param] = check_plain($form_state['values']['options'][$key]);
    }
  }
}