Issue #2372893 by idebr, Wim Leers: Text editor configuration UI does not update correctly when switching editors

8.0.x
Alex Pott 2015-01-23 12:44:37 +00:00
parent 0f93b42d0b
commit c0b346b75c
2 changed files with 13 additions and 3 deletions

View File

@ -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);
}

View File

@ -82,6 +82,14 @@ class EditorAdminTest extends WebTestBase {
$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 @@ class EditorAdminTest extends WebTestBase {
$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.