0

I want to enable the WYSIWYG editor so I can create HTML mail from webform email templates. (Yes, I know some people don't like HTML in emails.) I have created a module, and I'm using this code:

function mymodulename_form_alter(&$element, &$form_state, $context) {
  if (isset($element['template']['template'])) {
    $element['template']['template']['#wysiwyg'] = true;
    $element['template']['template']['#type'] = 'text_format';
  }
}

This is great, and the WYSIWYG is enabled. Unfortunately it changes the values from a string to an array, and I can't figure out how to convert them back again. I was hoping this would help, but hook_field_attach_presave() doesn't seem to fire for that form. In fact, I can't find any hooks that fire for that form.

Any suggestions?

3 Answers 3

1

HTML emails have a different standard than WYSIWYG editors. For example HTML emails use tables instead of divs, you can't use paddings etc.

So I don't think that HMLT email creating with WYSIWYG editor is a good idea...

2
  • Thanks, but I'm not planning on using either divs or tables. All I'm really after is the ability to have non-technical users bold some text, and make other simple changes. They shouldn't have to learn HTML to do that. So while perhaps using the full features of the WYSIWYG may not work for everyone, it is the best solution for this case.
    – Pat
    Mar 20, 2013 at 3:11
  • I see. I have just downloaded webform module and I can use the "Confirmation message" field with WYSIWYG editor. Mar 20, 2013 at 7:32
0

Thanks for your message. That helped me finding a solution! Here it is.

dd_fixes is the name of my module.

function dd_fixes_form_webform_email_edit_form_alter(&$form, &$form_state, $form_id) {
    $form['template']['template']["#wysiwyg"] = true;
    $form['template']['template']['#type'] = 'text_format';
    $form['template']['template']['#format'] = 'full_html';

    $new = array("dd_fixes_webform_email_edit_form_submit");
    $form["#submit"] = array_merge($new,$form["#submit"]);
} 

function dd_fixes_webform_email_edit_form_submit($form, &$form_state) {
    $form_state['values']['template'] = $form_state['values']['template']['value'];
}
0

There is a separate module for that: Webform Email Input Filter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.