diff --git a/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php b/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php index ba054a6..08ada45 100644 --- a/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php +++ b/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php @@ -234,20 +234,15 @@ public function settingsForm(array $form, FormStateInterface $form_state, Editor /** * {@inheritdoc} */ - public function settingsFormSubmit(array $form, FormStateInterface $form_state) { - // Modify the toolbar settings by reference. The values in - // $form_state->getValue(array('editor', 'settings')) will be saved directly - // by editor_form_filter_admin_format_submit(). - $toolbar_settings = &$form_state->getValue(array('editor', 'settings', 'toolbar')); - + 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. - $toolbar_settings['rows'] = json_decode($toolbar_settings['button_groups'], TRUE); - unset($toolbar_settings['button_groups']); + $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(array('editor', 'settings', 'plugins'))) { - $form_state->unsetValue(array('editor', 'settings', 'plugin_settings')); + if ($form_state->hasValue('plugins')) { + $form_state->unsetValue('plugin_settings'); } } diff --git a/core/modules/editor/src/Plugin/EditorBase.php b/core/modules/editor/src/Plugin/EditorBase.php index bd429d1..3456e44 100644 --- a/core/modules/editor/src/Plugin/EditorBase.php +++ b/core/modules/editor/src/Plugin/EditorBase.php @@ -3,6 +3,7 @@ namespace Drupal\editor\Plugin; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Form\SubformStateInterface; use Drupal\Core\Plugin\PluginBase; use Drupal\editor\Entity\Editor; @@ -61,6 +62,9 @@ public function settingsFormSubmit(array $form, FormStateInterface $form_state) * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { + if ($form_state instanceof SubformStateInterface) { + $form_state = $form_state->getCompleteFormState(); + } return $this->settingsForm($form, $form_state, $form_state->get('editor')); } @@ -68,6 +72,9 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta * {@inheritdoc} */ public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { + if ($form_state instanceof SubformStateInterface) { + $form_state = $form_state->getCompleteFormState(); + } return $this->settingsFormValidate($form, $form_state); } @@ -75,6 +82,9 @@ public function validateConfigurationForm(array &$form, FormStateInterface $form * {@inheritdoc} */ public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { + if ($form_state instanceof SubformStateInterface) { + $form_state = $form_state->getCompleteFormState(); + } return $this->settingsFormSubmit($form, $form_state); }