On a Drupal site using the WYSIWYG module, when editing a Webform node, I only get a WYSIWYG editor for the field "Confirmation message or redirect URL," but not for "Description."

I had some issues about the WYSIWYG editor not working with certain modules, which I thought was the WYSIWYG module's fault. But after bringing this up with the author of that module, he thinks the usage of filter_form() is simply confusing. After our dialogue, he wrote documentation about the usage of filter_form() expected by the WYSIWYG module. I also applied the same usage of filter_form() and fixed the Views UI module.

Attached is a patch to correct this. The "Input Format" section is now properly displayed below and applied to the "Description" field. Since the format saved is applied to the description when the node is viewed anyway, I thought this was appropriate.

I didn't fix the lack of WYSIWYG module support for the field "Confirmation message or redirect URL." However, someone may be interested in reading the documentation linked below and to add the proper support for the WYSIWYG module.

Links of interest

CommentFileSizeAuthor
#6 webform.module.patch613 bytesshaisachs
webform_body_wysiwyg.patch635 bytesremi

Comments

quicksketch’s picture

Yep, I agree, this is definitely a problem with Webform itself. We currently position the filter form below the confirmation message because the same input format field is used for both the Description and the Confirmation Message. While moving the filter form makes it work for one of the two fields, we really should be adding another input format fieldset, so there's one beneath each option.

remi’s picture

Oh, I didn't realise the filter was applied on both fields, not just "Description." My mistake.

However, because the input filter was positioned below the second field, the WYSIWYG editor was getting applied to that field, and not "Description," where I needed it the most, in my case.

I think what is necessary for this to work is the following:

  1. A new "confirmation_filter" column in the "webform" table.
  2. A new "confirmation_filter" value in the $node object.
  3. Another "input format" section below the "Confirmation" field.

For 3, I think something like the line below should work:

$form['webform']['settings']['confirmation_format'] = filter_form($node->confirmation_format, 1, array('confirmation_format'));
quicksketch’s picture

Yep, agreed on all counts. Typically the textarea and input format fieldset are grouped together in the same FAPI element. WYSIWYG API may or may not depend on them being grouped together to operate property. Webform also puts all it's data in $node->webform, so we'd probably put the data in $node->webform['confirmation_filter'].

mtndan’s picture

Version: 5.x-2.4 » 6.x-2.6

Nate or anyone - how can I get a wysiwyg toolbar to appear on the "description" text area? I'm using the Drupal 6 version of both webform and wysiwyg api. Thanks!

alan d.’s picture

A simple hack to move the filter seems to help, but you loss the WYSIWYG editor from the "Confirmation message or redirect URL". Simply find this line in the the webform.module, $form['webform']['settings']['format'] = filter_form($node->format);, and move it up 8 lines so that it lies in between the body and confirmation form elements. It was on about line 670.

Any progress on splitting the fields to enable the editor?

shaisachs’s picture

StatusFileSize
new613 bytes

Lovely patch! I don't think the confirmation message should have a format anyway - or in any case, if it does it should be separated from the redirection page; it's too easy for users to get things mixed up.

I've rolled a similar patch to #1 for 6.x-2.6, attached. It's just a difference of line numbers.

quicksketch’s picture

Status: Active » Needs work

A lot of users use the confirmation page with the PHP input format to print out information about the submission. We need to make the input format available for both fields.

kingandy’s picture

Title: Support for WYSIWYG module » Separate input formats for body and confirmation

Updating title to reflect task instead of goal.

Also: It would be awesome for this to be backported to 5.x when it's finished...

quicksketch’s picture

Status: Needs work » Closed (duplicate)

I've corrected this problem as part of a 3.x feature to separate the node edit form from Webform configuration, see #492806: Separate Webform Configuration from node/edit/x Form. This was necessary since now that the confirmation field is displayed separately from the body, it absolutely needs a different Input Format fielset. New feature development has stopped on the 2.x branch, and it's unlikely that this change will be backported to Drupal 5.

Steven Merrill’s picture

Nate,

If someone posted a working patch for the 2.x branch to add an extra input format widget, would it be committed?

mlncn’s picture

Not to cash in on the Celtics jacket now, but is there a 3.x release candidate estimate or a backport possible? I messed around and no easy hacks to make it work.

Gabriel R.’s picture

Hurting for this.

beyond67’s picture

Any updates regarding this?

alan d.’s picture

Title: Separate input formats for body and confirmation » Separate input formats for body and confirmation (WebForm 6.x-2.x)
Component: User interface » Documentation
Status: Closed (duplicate) » Active

Change WYSIWYG target textarea for WebForm 2.x without a module hack:

Option 1: Move the WYSIWYG to the description field rather than the confirmation field.

<?php

/**
 * Implementation of hook_form_alter().
 */
function HOOK_form_alter(&$form, $form_state, $form_id) {
  if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] .'_node_form' == $form_id) {
    if ($form['type']['#value'] == 'webform') {
      $confirmation = $form['webform']['settings']['confirmation'];
      unset($form['webform']['settings']['confirmation']);
      $form['webform']['settings']['confirmation'] = $confirmation;
    }
  }
}
?>

Option 2: Add two WYSIWYG editors.

The confirmation input format value does not get saved.

Needs testing. This is working on the one site that we have tried it on.

<?php

/**
 * Implementation of hook_form_alter().
 */
function HOOK_form_alter(&$form, $form_state, $form_id) {
  if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] .'_node_form' == $form_id) {
    if ($form['type']['#value'] == 'webform') {
      // Move the format above the confirmation
      $confirmation = $form['webform']['settings']['confirmation'];
      unset($form['webform']['settings']['confirmation']);
      $form['webform']['settings']['confirmation'] = $confirmation;
    
      // Hide the confirmation and create a new one that updates the hidden field
      // using #validate handler.
      $form['webform']['settings']['confirmation']['#access'] = FALSE;
      $form['webform']['settings']['confirmation_custom'] = array(
        '#tree' => TRUE,
      );
    
      $form['webform']['settings']['confirmation_custom']['confirmation'] = array(
        '#type' => 'textarea',
        '#title' => t('Confirmation message or redirect URL'),
        '#description' => t('Message to be shown upon successful submission or a path to a redirect page. Preface message with <em>message:</em> for a simple message that does not require a page refresh. Redirect pages must start with <em>http://</em> for external sites or <em>internal:</em> for an internal path. i.e. <em>http://www.example.com</em> or <em>internal:node/10</em>'),
        '#default_value' => $form['#node']->webform['confirmation'],
        '#cols' => 40,
        '#rows' => 10,
      );
      $form['webform']['settings']['confirmation_custom']['format'] = filter_form($form['#node']->format);
    
      array_unshift($form['#validate'], 'webform_confirmation_custom_validate');
    }
  }
}

function webform_confirmation_custom_validate($form, &$form_state) {
  form_set_value($form['webform']['settings']['confirmation'], $form_state['values']['webform']['confirmation_custom']['confirmation'], $form_state);
}

?>
quicksketch’s picture

Alan D, I'm not sure what to do with this information. 2.x is going to be short-lived, it doesn't make sense to make a documentation page in the Webform handbook for this, yet the issue queue certainly is not the place for long-term documentation. Thanks for sharing your solution, but what do you think we should do with it?

alan d.’s picture

Status: Active » Closed (duplicate)

I do not know where the HowTo's for WebForm's exist, so added here. I'll close the issue and google can direct users here as required. :)

We've been hacking every webform module in production over the last 6 or so months, and this will put a stop to this practice in the period between now and 6.x-3.x stable is released.

Recap for those that skipped all the way to the bottom of the thread. The latest branch does not have this issue. Ref #492806: Separate Webform Configuration from node/edit/x Form