Hi,

We have implemented a moderation system using workbench, where users with the same role can do one edit, then no longer edit the content.
To achieve this, we have overridedn hook_workbench_moderation_states_next_alter and removed the possible transitions for users who already edited so the moderation form is automatically removed when there are no next states available.

But we've found that the label "Set moderation state" still appears (see screenshot).

This happens because in file workbench_moderation.node.inc, line: 185, the label is statically prepended to the rendered form:

      $moderate_form = drupal_get_form('workbench_moderation_moderate_form', $node_current);
      $row['data']['moderation'] .= '<div class="moderation-actions">' . t('Set moderation state: !moderation-actions-form', array('!moderation-actions-form' => drupal_render($moderate_form))) . '</div>';

Doesn't the code should check if the form is really valid? Something like:

      $moderate_form = drupal_get_form('workbench_moderation_moderate_form', $node_current);
      if (isset($moderate_form['state'])) {
        $moderate_form['state']['#title'] = t('Set moderation state');
        $moderate_form['state']['#title_display'] = 'before';
        $row['data']['moderation'] .= '<div class="moderation-actions">' . t('!moderation-actions-form', array('!moderation-actions-form' => drupal_render($moderate_form))) . '</div>';
      }

Comments

cristiroma’s picture

I saw that when there are no workflow states, the form['#access'] is FALSE as well.
Attaching a patch - works for us, not sure it's the best solution.