When there is only a single format possible and thus access to the format select box is disabled, the wysiwyg module adds a hidden input field containing that format, so the related JS knows which wysiwyg profile to initialize.

from wysiwyg.module:

if (!$format_field['format']['#access']) {
    $format_field['wysiwyg'] = array(
      '#type' => 'hidden',
      '#name' => $format_field['format']['#name'],
      '#value' => $format_id,
      '#attributes' => array(
        'id' => $format_field['format']['#id'],
        'class' => array('wysiwyg'),
      ),
    );

However, under certain circumstances the better formats module disables the whole format fieldset, in which this hidden input field was inserted by wysiwyg, through its #access property.

from better_formats.module:

// Hide the entire text format fieldset if the user is not supposed to see
  // anything inside it.
  if (!$show_selection && !$show_tips && !$show_tips_link) {
    $element['format']['#access'] = FALSE;
  }

wysiwyg's JS now doesn't know anymore about the format and doesn't initialize any editor at all.

I found several related issues here in the queue but none of them came to the point of clarifying the issue properly or were related to D6 so I thought reporting a new one would be a better idea.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dragonwize’s picture

Confirmed.

I dealt with this in D6 but the code was recently switched to an run after instead of a run instead of. It needs to have the same idea done as D6.

dragonwize’s picture

Status: Active » Fixed

Changed the fieldset to a container instead of disabling access.

Committed. Thanks.

Status: Fixed » Closed (fixed)

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

rocketeerbkw’s picture

Status: Closed (fixed) » Active
FileSize
555 bytes

I believe there is another place this needs to be fixed:

if (!$show_selection) {
  $element['format']['format']['#access'] = FALSE;
}

This is causing my issues in #1715790: Text Editor Is Missing For All Users Except Admin since this early in the code there's no way to know if there is only one Text Format available and when $element['format']['format']['#access'] = FALSE; is used, WYSIWYG will assume there is only one Text Format.

Edit: I spoke too soon, it looks like $element['format']['#type'] = 'container'; won't hide anything at all. I believe that removing the #access is correct for both locations, but something other than changing #type to container needs to be used.

rocketeerbkw’s picture

How many times am I allowed to flip flop on an issue? I think there's a bug in WYSIWYG related to setting #access to FALSE and having multiple text formats available. See #934976: Provide method to hide input format fields without disabling WYSIWYG

With that issue fixed, $element['format']['format']['#access'] = FALSE; becomes the approved method for disabling format selector and not breaking WYSIWYG. So you should actually revert the orginal fix in this issue and use $element['format']['format']['#access'] = FALSE;.

rocketeerbkw’s picture

Issue summary: View changes

Fixed formatting and mentioned the files containing code extracts.

fonant’s picture

Issue summary: View changes

I get this problem, to use the WYSIWYG editor for node bodies the user has to have the "Show format selection for nodes" permission, which then keeps the format selector and thus the WYSIWYG editor JS is added.

I have found that standard Better Formats, with WYSIWYG 7.x-2.2, plus the wysiwyg-one-format.934976.23-alt.patch patch from #934976-23: Provide method to hide input format fields without disabling WYSIWYG fixes this problem.

  • dragonwize committed 3b148f6 on 8.x-1.x
    Fixed #1699846 by dragonwize: Change fieldset to container instead of...