Markup component breaks WYSIWYG

chromix - February 23, 2009 - 16:33
Project:Webform
Version:6.x-2.7
Component:User interface
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review
Description

When creating or editing a Markup component in a Webform, WYSIWYG (with TinyMCE 3) ignores the value field and instead creates an editor around the token help. I tried removing token help from the Markup component, and instead WYSIWYG created an editor around the Input Type selector...!

Not sure if this should be addressed here or in the WYSIWYG bug queue, but for now I'm posting it here.

#1

chromix - February 23, 2009 - 17:02

I should also note I'm using the latest version of WYSIWYG and TinyMCE. I've also posted this in the WYSIWYG bug queue:
http://drupal.org/node/381174

#2

sun - February 23, 2009 - 17:42

Hm. Webform should produce the same output like filter_form() would. I did not try to replicate this issue, but from the description it sounds like it does not.

#3

quicksketch - June 16, 2009 - 05:41
Version:5.x-2.6» 6.x-2.7

Seems that this is still the case even in 6.x and the latest Webforms. I haven't seen WYSIWYG "create an editor around the token help", but it doesn't create an editor at all and may through a JS error. My guess is that Webform doesn't group the textarea and the input format in a dedicated grouping of fields in the FAPI array, which throws off WYSIWYG somehow.

#4

didymo - June 20, 2009 - 05:00

Thanks for adding this. I thought I was going nuts.

Drupal-6-12
WYSIWYG-6.x-2.0
TInyMCE-3.2.4.1
WebForm-6.x-2.7

There is no formatting ability in the form element area at all. No WYSIWYG, when I use html to set out paragraphs the tags are stripped.

Ideas for temporary hacks to get around this great fully received.

Regards,

Ashley

#5

mrfelton - July 27, 2009 - 10:56

subs

#6

awolfey - August 5, 2009 - 18:39

subscribe
Experiencing this with fck.

#7

awolfey - August 5, 2009 - 19:00

I was able to get this to work by patching markup.inc.

I put a grouping "['markup']" around the markup ['value'] and the filter ['format'].

I'm not sure what else this might break.

Can provide a patch if desired.

function _webform_edit_markup($currfield) {
  $edit_fields = array();
  $edit_fields['advanced']['mandatory'] = array(); // Do not render the mandatory checkbox.
  $edit_fields['markup']['value'] = array(
    '#type' => 'textarea',
    '#title' => t('Value'),
    '#default_value' => $currfield['value'],
    '#description' => t('Markup allows you to enter custom HTML or PHP logic into your form.'). theme('webform_token_help'),
    '#weight' => -1,
  );
  // Add the filter form.
  $edit_fields['markup']['format'] = filter_form($currfield['extra']['format'], 0, array('extra', 'format'));

  // No description for markup.
  $edit_fields['extra']['description'] = array();

  return $edit_fields;
}

#8

awolfey - August 5, 2009 - 20:20

This will also be needed in webform_components.inc

In function webform_component_update($component) add this

  if (isset($component['markup']['value'])) {
    $component['value'] = $component['markup']['value'];
  }

above this line.

  $component['value'] = isset($component['value']) ? $component['value'] : NULL;

In function webform_component_insert($component)

add

  if (isset($component['markup']['value'])) {
    $component['value'] = $component['markup']['value'];
  }

above this line.

  $component['value'] = isset($component['value']) ? $component['value'] : NULL;

Sorry for no patch. Will get around to it.

Basically, we are wrapping the field and format filter together for markup editing. Then we remove the wrapper before saving the form component so the display and component list works.

#9

sun - August 5, 2009 - 19:53

@awolfey: Can you provide a proper patch?

#10

awolfey - August 5, 2009 - 20:00

Ummmm. Don't try this yet...

#11

awolfey - August 5, 2009 - 20:24

I made edits to #8 that should work. However, this is largely untested, so use at own risk.

I am slammed at the moment, but I will get a patch rolled tonight or tomorrow morning. (Patching not my strong suit.)

#12

awolfey - August 6, 2009 - 00:22
Status:active» needs review

Here is a patch. It is working for me, but I haven't tested it thoroughly.

AttachmentSize
webform6x-2-wysiwyg.patch 3.47 KB

#13

jhodgdon - August 24, 2009 - 17:45

Just a note that WYSIWYG will put an HTML editor on any text area field that is immediately followed by an input format field named 'format', and these two fields have to be in the same level of the array.

So I think it would be better just to move the input format up to the next level of the array, rather than moving both of them into 'markup' part of the array, since that obviously resulted in some hacking being necessary farther down in the patch.

#14

sun - August 24, 2009 - 17:52

+++ components/markup.inc 6 Aug 2009 00:05:40 -0000
@@ -34,7 +34,7 @@
-  $edit_fields['value'] = array(
+  $edit_fields['markup']['value'] = array(
     '#type' => 'textarea',
     '#title' => t('Value'),
     '#default_value' => $currfield['value'],

Simply define

'#parents' => array('value'),

here and you can remove the other changes - in the insert handler.

This review is powered by Dreditor.

#15

hepabolu - September 1, 2009 - 15:16

I get the impression I need this patch, but I'm not proficient enough in PHP to understand the comments made in #14 to apply them to (what seems to be) the patch provided in #12. Could someone please elaborate or update the patch?

Thank you.

 
 

Drupal is a registered trademark of Dries Buytaert.