public function OpenlayersPluginFormBase::submitForm in Openlayers 8.4
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormInterface::submitForm
File
- src/
Form/ OpenlayersPluginFormBase.php, line 125
Class
- OpenlayersPluginFormBase
- Provides a base form for the settings for Openlayers plugins.
Namespace
Drupal\openlayers\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$form_state
->cleanValues();
// The plugin configuration is stored in the 'data' key in the form, which is then passed through for submission.
$this->olPlugin
->submitConfigurationForm($form['data'], SubformState::createForSubform($form['data'], $form, $form_state));
$this->olPlugin
->setWeight($form_state
->getValue('weight'));
if (!$this->olPlugin
->getUuid()) {
$definition = $this->olPlugin
->getPluginDefinition();
$configuration = $this->olPlugin
->getConfiguration();
$configuration['ol_id'] = $form_state
->getValue('ol_id');
$plugin_type = $definition['type'];
$this->olMap
->{'addMap' . ucwords($plugin_type)}($configuration);
}
$this->olMap
->save();
// $node->getCacheTags()
Cache::invalidateTags([
'config:openlayers.map.ol_map2',
]);
$this
->messenger()
->addStatus($this
->t('The Settings for the plugin were successfully saved.'));
$form_state
->setRedirectUrl($this->olMap
->toUrl('edit-form'));
}