diff --git a/core/modules/editor/editor.module b/core/modules/editor/editor.module index 770f36825a94b2904c80506580331307348964c8..2c53d2489a2eed38f40b234a130ec9f51ca03cbe 100644 --- a/core/modules/editor/editor.module +++ b/core/modules/editor/editor.module @@ -90,7 +90,8 @@ function editor_form_filter_admin_overview_alter(&$form, FormStateInterface $for * Implements hook_form_BASE_FORM_ID_alter() for 'filter_format_form'. */ function editor_form_filter_format_form_alter(&$form, FormStateInterface $form_state) { - if (!$editor = $form_state->get('editor')) { + $editor = $form_state->get('editor'); + if ($editor === NULL) { $format_id = $form_state->getFormObject()->getEntity()->id(); $editor = editor_load($format_id); $form_state->set('editor', $editor); @@ -168,7 +169,8 @@ function editor_form_filter_format_form_alter(&$form, FormStateInterface $form_s */ function editor_form_filter_admin_format_editor_configure($form, FormStateInterface $form_state) { $editor = $form_state->get('editor'); - if ($editor_value = $form_state->getValue(array('editor', 'editor'))) { + $editor_value = $form_state->getValue(array('editor', 'editor')); + if ($editor_value !== NULL) { if ($editor_value === '') { $form_state->set('editor', FALSE); } diff --git a/core/modules/editor/src/Tests/EditorAdminTest.php b/core/modules/editor/src/Tests/EditorAdminTest.php index 020aa587b842e9e809d791833cf152005ffa290b..b151896bf1de01f481f9b4bb9a07495acd1630d6 100644 --- a/core/modules/editor/src/Tests/EditorAdminTest.php +++ b/core/modules/editor/src/Tests/EditorAdminTest.php @@ -82,6 +82,14 @@ public function testAddEditorToExistingFormat() { $edit['editor[settings][ponies_too]'] = FALSE; $this->drupalPostForm(NULL, $edit, t('Save configuration')); $this->verifyUnicornEditorConfiguration('filtered_html', FALSE); + + // Switch back to 'None' and check the Unicorn Editor's settings are gone. + $edit = array( + 'editor[editor]' => '', + ); + $this->drupalPostAjaxForm(NULL, $edit, 'editor_configure'); + $unicorn_setting = $this->xpath('//input[@name="editor[settings][ponies_too]" and @type="checkbox" and @checked]'); + $this->assertTrue(count($unicorn_setting) === 0, "Unicorn Editor's settings form is no longer present."); } /** @@ -125,7 +133,7 @@ protected function selectUnicornEditor() { $this->assertTrue(((string) $options[0]) === 'None', 'Option 1 in the Text Editor select is "None".'); $this->assertTrue(((string) $options[1]) === 'Unicorn Editor', 'Option 2 in the Text Editor select is "Unicorn Editor".'); $this->assertTrue(((string) $options[0]['selected']) === 'selected', 'Option 1 ("None") is selected.'); - // Ensure the none option is selected + // Ensure the none option is selected. $this->assertNoRaw(t('This option is disabled because no modules that provide a text editor are currently enabled.'), 'Description for select absent that tells users to install a text editor module.'); // Select the "Unicorn Editor" editor and click the "Configure" button.