Loading src/Element/WebformHtmlEditor.php +6 −4 Original line number Diff line number Diff line Loading @@ -72,8 +72,9 @@ class WebformHtmlEditor extends FormElement { $element['value']['#required'] = $element['#required']; } // If HTML disabled return simple CodeMirror HTML editor. $disabled = \Drupal::config('webform.settings')->get('html_editor.disabled') ?: $element['#format']; // If HTML disabled and no #format is specified return simple CodeMirror // HTML editor. $disabled = \Drupal::config('webform.settings')->get('html_editor.disabled') ?: ($element['#format'] === FALSE); if ($disabled) { $element['value'] += [ '#type' => 'webform_codemirror', Loading @@ -83,8 +84,9 @@ class WebformHtmlEditor extends FormElement { return $element; } // If #context and format is defined return 'text_format' element. $format = \Drupal::config('webform.settings')->get('html_editor.format') ?: $element['#format']; // If #format or 'webform.settings.html_editor.format' is defined return // a 'text_format' element. $format = $element['#format'] ?: \Drupal::config('webform.settings')->get('html_editor.format'); if ($format) { $element['value'] += [ '#type' => 'text_format', Loading src/Form/WebformHandlerFormBase.php +6 −0 Original line number Diff line number Diff line Loading @@ -84,6 +84,12 @@ abstract class WebformHandlerFormBase extends FormBase { } } // Add meta data to webform handler form. // This information makes it a little easier to alter a handler's form. $form['#webform_id'] = $this->webform->id(); $form['#webform_handler_id'] = $this->webformHandler->getHandlerId(); $form['#webform_handler_plugin_id'] = $this->webformHandler->getPluginId(); $request = $this->getRequest(); $form['description'] = [ Loading src/Tests/Element/WebformElementHtmlEditorTest.php +5 −1 Original line number Diff line number Diff line Loading @@ -42,10 +42,14 @@ class WebformElementHtmlEditorTest extends WebformTestBase { public function testHtmlEditor() { $this->drupalLogin($this->rootUser); // Check that HTML editor is enabled. $this->drupalGet('webform/test_element_html_editor'); // Check that HTML editor is enabled. $this->assertRaw('<textarea class="js-html-editor form-textarea resize-vertical" data-drupal-selector="edit-webform-html-editor-value" id="edit-webform-html-editor-value" name="webform_html_editor[value]" rows="5" cols="60">Hello <b>World!!!</b></textarea>'); // Check that CodeMirror is displayed when #format: FALSE. $this->assertRaw('<textarea data-drupal-selector="edit-webform-html-editor-codemirror-value" class="js-webform-codemirror webform-codemirror html form-textarea resize-vertical" data-webform-codemirror-mode="text/html" id="edit-webform-html-editor-codemirror-value" name="webform_html_editor_codemirror[value]" rows="5" cols="60">Hello <b>World!!!</b></textarea>'); // Disable HTML editor. $this->drupalPostForm('admin/structure/webform/config/elements', ['html_editor[disabled]' => TRUE], t('Save configuration')); Loading tests/modules/webform_test/config/install/webform.webform.test_element_html_editor.yml +5 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,11 @@ elements: | '#title': 'webform_html_editor (format)' '#default_value': 'Hello <b>World!!!</b>' '#format': 'basic_html' webform_html_editor_codemirror: '#type': webform_html_editor '#title': 'webform_html_editor_codemirror (none)' '#default_value': 'Hello <b>World!!!</b>' '#format': false css: '' javascript: '' settings: Loading Loading
src/Element/WebformHtmlEditor.php +6 −4 Original line number Diff line number Diff line Loading @@ -72,8 +72,9 @@ class WebformHtmlEditor extends FormElement { $element['value']['#required'] = $element['#required']; } // If HTML disabled return simple CodeMirror HTML editor. $disabled = \Drupal::config('webform.settings')->get('html_editor.disabled') ?: $element['#format']; // If HTML disabled and no #format is specified return simple CodeMirror // HTML editor. $disabled = \Drupal::config('webform.settings')->get('html_editor.disabled') ?: ($element['#format'] === FALSE); if ($disabled) { $element['value'] += [ '#type' => 'webform_codemirror', Loading @@ -83,8 +84,9 @@ class WebformHtmlEditor extends FormElement { return $element; } // If #context and format is defined return 'text_format' element. $format = \Drupal::config('webform.settings')->get('html_editor.format') ?: $element['#format']; // If #format or 'webform.settings.html_editor.format' is defined return // a 'text_format' element. $format = $element['#format'] ?: \Drupal::config('webform.settings')->get('html_editor.format'); if ($format) { $element['value'] += [ '#type' => 'text_format', Loading
src/Form/WebformHandlerFormBase.php +6 −0 Original line number Diff line number Diff line Loading @@ -84,6 +84,12 @@ abstract class WebformHandlerFormBase extends FormBase { } } // Add meta data to webform handler form. // This information makes it a little easier to alter a handler's form. $form['#webform_id'] = $this->webform->id(); $form['#webform_handler_id'] = $this->webformHandler->getHandlerId(); $form['#webform_handler_plugin_id'] = $this->webformHandler->getPluginId(); $request = $this->getRequest(); $form['description'] = [ Loading
src/Tests/Element/WebformElementHtmlEditorTest.php +5 −1 Original line number Diff line number Diff line Loading @@ -42,10 +42,14 @@ class WebformElementHtmlEditorTest extends WebformTestBase { public function testHtmlEditor() { $this->drupalLogin($this->rootUser); // Check that HTML editor is enabled. $this->drupalGet('webform/test_element_html_editor'); // Check that HTML editor is enabled. $this->assertRaw('<textarea class="js-html-editor form-textarea resize-vertical" data-drupal-selector="edit-webform-html-editor-value" id="edit-webform-html-editor-value" name="webform_html_editor[value]" rows="5" cols="60">Hello <b>World!!!</b></textarea>'); // Check that CodeMirror is displayed when #format: FALSE. $this->assertRaw('<textarea data-drupal-selector="edit-webform-html-editor-codemirror-value" class="js-webform-codemirror webform-codemirror html form-textarea resize-vertical" data-webform-codemirror-mode="text/html" id="edit-webform-html-editor-codemirror-value" name="webform_html_editor_codemirror[value]" rows="5" cols="60">Hello <b>World!!!</b></textarea>'); // Disable HTML editor. $this->drupalPostForm('admin/structure/webform/config/elements', ['html_editor[disabled]' => TRUE], t('Save configuration')); Loading
tests/modules/webform_test/config/install/webform.webform.test_element_html_editor.yml +5 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,11 @@ elements: | '#title': 'webform_html_editor (format)' '#default_value': 'Hello <b>World!!!</b>' '#format': 'basic_html' webform_html_editor_codemirror: '#type': webform_html_editor '#title': 'webform_html_editor_codemirror (none)' '#default_value': 'Hello <b>World!!!</b>' '#format': false css: '' javascript: '' settings: Loading