function CKEditor::submitConfigurationForm
Same name in other branches
- 8.9.x core/modules/ckeditor/src/Plugin/Editor/CKEditor.php \Drupal\ckeditor\Plugin\Editor\CKEditor::submitConfigurationForm()
Overrides EditorBase::submitConfigurationForm
File
-
core/
modules/ ckeditor/ src/ Plugin/ Editor/ CKEditor.php, line 288
Class
- CKEditor
- Defines a CKEditor-based text editor for Drupal.
Namespace
Drupal\ckeditor\Plugin\EditorCode
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
// The rows key is not built into the form structure, so decode the button
// groups data into this new key and remove the button_groups key.
$form_state->setValue([
'toolbar',
'rows',
], json_decode($form_state->getValue([
'toolbar',
'button_groups',
]), TRUE));
$form_state->unsetValue([
'toolbar',
'button_groups',
]);
// Remove the plugin settings' vertical tabs state; no need to save that.
if ($form_state->hasValue('plugins')) {
$form_state->unsetValue('plugin_settings');
}
// Ensure plugin settings are only saved for plugins that are actually
// enabled.
$about_to_be_saved_editor = Editor::create([
'editor' => 'ckeditor',
'settings' => [
'toolbar' => $form_state->getValue('toolbar'),
'plugins' => $form_state->getValue('plugins'),
],
]);
$enabled_plugins = _ckeditor_get_enabled_plugins($about_to_be_saved_editor);
$plugin_settings = $form_state->getValue('plugins', []);
foreach (array_keys($plugin_settings) as $plugin_id) {
if (!in_array($plugin_id, $enabled_plugins, TRUE)) {
unset($plugin_settings[$plugin_id]);
}
}
$form_state->setValue('plugins', $plugin_settings);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.