public function OLMap::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/ Map/ OLMap/ OLMap.php, line 324 - Map: Map.
Class
- OLMap
- Class OLMap.
Namespace
Drupal\openlayers\Plugin\Map\OLMapCode
public function optionsFormSubmit(array $form, array &$form_state) {
// So we can use the map API instead of working with arrays.
parent::optionsFormSubmit($form, $form_state);
$limit_extent = $this
->getOption(array(
'view',
'limit_extent',
), '');
$extent = $this
->getOption(array(
'view',
'extent',
), '');
if (empty($limit_extent) || $limit_extent == 'custom' && empty($extent)) {
unset($form_state['values']['options']['view']['extent']);
unset($form_state['values']['options']['view']['limit_extent']);
}
$capabilities = array();
if (isset($form_state['values']['options']['capabilities']['enabled']) && (bool) $form_state['values']['options']['capabilities']['enabled'] == TRUE) {
$elements = (array) $form_state['values']['options']['capabilities']['options']['table']['elements'];
uasort($elements, function ($a, $b) {
return $a['weight'] - $b['weight'];
});
foreach ($elements as $data) {
if ((bool) $data['enabled'] == TRUE && !empty($data['text'])) {
$capabilities[$data['machine_name']] = $data['text'];
}
}
$form_state['values']['options']['capabilities']['options']['table'] = $capabilities;
}
else {
$this
->clearOption('capabilities');
unset($form_state['values']['options']['capabilities']);
}
parent::optionsFormSubmit($form, $form_state);
}