You are here

function openlayers_control_form_options_submit in Openlayers 7.3

Control options config form submit handler.

File

modules/openlayers_ui/src/Plugin/export_ui/OpenlayersControls.inc, line 164
CTools Export UI plugin definition for controls.

Code

function openlayers_control_form_options_submit($form, &$form_state) {
  if (isset($form_state['values']['options'])) {
    $form_state['item']->options = array_merge((array) $form_state['item']->options, (array) $form_state['values']['options']);
  }
  if (($control = \Drupal\openlayers\Openlayers::load('Control', $form_state['item'])) == TRUE) {
    if (!empty($form_state['item']->attachToMap) && ($map = \Drupal\openlayers\Openlayers::load('map', $form_state['item']->attachToMap)) == TRUE) {
      $controls = $map
        ->getOption('controls', array());
      $controls[] = $control
        ->getMachineName();
      $map
        ->setOption('controls', $controls);
      \Drupal\openlayers\Openlayers::save($map);
      unset($form_state['item']->attachToMap);
    }
    $control
      ->optionsFormSubmit($form, $form_state);
  }
}