Skip to content
Snippets Groups Projects
Commit 814089c9 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #1950634 by Wim Leers: Fatal error when creating a new text format with...

Issue #1950634 by Wim Leers: Fatal error when creating a new text format with a text editor while JS is disabled.
parent e5774f5b
No related branches found
No related tags found
No related merge requests found
......@@ -68,6 +68,13 @@ function testAdmin() {
$this->assertTrue(((string) $options[1]) === 'CKEditor', 'Option 2 in the Text Editor select is "CKEditor".');
$this->assertTrue(((string) $options[0]['selected']) === 'selected', 'Option 1 ("None") is selected.');
// Select the "CKEditor" editor and click the "Save configuration" button.
$edit = array(
'editor[editor]' => 'ckeditor',
);
$this->drupalPost(NULL, $edit, t('Save configuration'));
$this->assertRaw(t('You must configure the selected text editor.'));
// Ensure the CKEditor editor returns the expected default settings.
$expected_default_settings = array(
'toolbar' => array(
......@@ -85,10 +92,7 @@ function testAdmin() {
);
$this->assertIdentical($ckeditor->getDefaultSettings(), $expected_default_settings);
// Select the "CKEditor" editor and click the "Configure" button.
$edit = array(
'editor[editor]' => 'ckeditor',
);
// Keep the "CKEditor" editor selected and click the "Configure" button.
$this->drupalPostAjax(NULL, $edit, 'editor_configure');
$editor = entity_load('editor', 'filtered_html');
$this->assertFalse($editor, 'No Editor config entity exists yet.');
......
......@@ -212,6 +212,7 @@ function editor_form_filter_admin_format_form_alter(&$form, &$form_state) {
$form['#submit'][] = array($plugin, 'settingsFormSubmit');
}
$form['#validate'][] = 'editor_form_filter_admin_format_validate';
$form['#submit'][] = 'editor_form_filter_admin_format_submit';
}
......@@ -242,6 +243,24 @@ function editor_form_filter_admin_form_ajax($form, &$form_state) {
return $form['editor']['settings'];
}
/**
* Additional validate handler for filter_admin_format_form().
*/
function editor_form_filter_admin_format_validate($form, &$form_state) {
// This validate handler is not applicable when using the 'Configure' button.
if ($form_state['triggering_element']['#name'] === 'editor_configure') {
return;
}
// When using this form with JavaScript disabled in the browser, the the
// 'Configure' button won't be clicked automatically. So, when the user has
// selected a text editor and has then clicked 'Save configuration', we should
// point out that the user must still configure the text editor.
if ($form_state['values']['editor']['editor'] !== '' && $form_state['editor'] === FALSE) {
form_set_error('editor][editor', t('You must configure the selected text editor.'));
}
}
/**
* Additional submit handler for filter_admin_format_form().
*/
......@@ -254,7 +273,7 @@ function editor_form_filter_admin_format_submit($form, &$form_state) {
}
// Create a new editor or update the existing editor.
if ($form_state['values']['editor']['editor'] !== '') {
if ($form_state['editor'] !== FALSE) {
// Ensure the text format is set: when creating a new text format, this
// would equal the empty string.
$form_state['editor']->format = $form['#format']->format;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment