As added in https://www.drupal.org/node/2888626 you can now select a text format for html editors in webform. It would be nice to have a separate text format for the email texts.

Usually there is a difference in what you want to send by email and what you want to type in markup elements.

Comments

SpadXIII created an issue. See original summary.

jrockowitz’s picture

Priority: Minor » Normal
Status: Active » Needs review
StatusFileSize
new2.03 KB

It is going to become very difficult to manage custom text formats for different HTML editor instances.

I recommend we try making it easy to use a form alter hook the tweak any HTML editor to use any specified text format.

When trying to use a form alter hook on the 'webform_handler_form', I ran into some minor issues like missing metadata and bug in the HTML editor's handling of the #format property.

The attached patch fixes these issues and allows the below code to force the Email's HTML editor to use the 'plain_text' format.

/**
 * Implements hook_form_FORM_ID_alter().
 */
function CUSTOM_MODULE_form_webform_handler_form_alter(&$form, FormStateInterface $form_state) {
  if ($form['#webform_handler_plugin_id'] === 'email') {
    $form['settings']['message']['body_custom_html']['#format'] = 'plain_text';
  }
}

BTW, I am willing to say this is now a 'Normal' priority ticket, especially because there are now some bug fixes and API improvements in the attached patch.

Status: Needs review » Needs work

The last submitted patch, 2: extra_text_format-2917021-2.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

jrockowitz’s picture

Status: Needs work » Needs review
StatusFileSize
new4.23 KB
jrockowitz’s picture

Status: Needs review » Fixed

I committed the attached patch and the code snippet from #2 will work with the latest dev release.

  • jrockowitz committed 3b3cbc0 on 8.x-5.x
    Issue #2917021 by jrockowitz: Extra text format option for email texts
    
spadxiii’s picture

Just a side-note for future reference: this patch seems to "break" the basic html markup webform element.

Before this patch, the #format of the element was not taken into account at all; it always used the webform setting 'html_editor.format'.
The basic html markup sets #format explicitly to FALSE. Use the advanced html markup field instead.

zenimagine’s picture

Where is this option ? I can not find it, I only have HTML editor settings in /admin/structure/webform/config/elements

jrockowitz’s picture

Status: Fixed » Needs review
StatusFileSize
new520 bytes

@#SpadXIII Does the attached patch fix #7?

spadxiii’s picture

Status: Needs review » Reviewed & tested by the community

@jrockowitz yes it does: now you get a ckeditor with the default text format in basic html markup elements.

jrockowitz’s picture

Status: Reviewed & tested by the community » Fixed

  • jrockowitz committed 71386bc on 8.x-5.x
    Issue #2917021 by jrockowitz, SpadXIII: Extra text format option for...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.