Compatibility with Multistep module

Created on 1 July 2015, almost 10 years ago
Updated 26 November 2024, 4 months ago

The automatic locking of content using this module fails when trying to lock a node page that is set up as a multistep form using the project https://www.drupal.org/project/multistep β†’ . This is because Multistep redirects form submission using a hardcoded $form_state['redirect'] value that does not take into account any pre-existing query values in the URL: the content_lock_token is always removed from the URL when moving to the next step in the form, and the user is presented with the manual lock message.

As the developers do not - for good reason - want to automatically lock content where the token is not in the URL, I have created a patch for the multistep module so that it will respect pre-existing URL queries and also provide an alter hook so that values can be added to its hardcoded $form_state['redirect'] programmatically, so that we can set the token on a multistep form submit without having to create it when a use simply visits the edit page without the correct token.

The steps to resolve this are to patch Multistep with the patch in https://www.drupal.org/node/2514748 β†’ , and then implement this code in a custom module:

/**
 * Implements hook_webform_redirect_query_alter().
 */
function MY_MODULE_webform_redirect_query_alter(&$context) {
  if ($context['nid']) {
    if ($token = drupal_get_token('node/' . $context['nid'] . '/edit')) {
      $context['query']['content_lock_token'] = $token;
    }
  }
}

This code will only currently work with node edit pages as multistep is only currently able to handle nodes.

✨ Feature request
Status

Closed: outdated

Version

2.0

Component

Documentation

Created by

πŸ‡¬πŸ‡§United Kingdom MrDaleSmith

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • πŸ‡ΊπŸ‡¦Ukraine AstonVictor

    I'm closing it because the issue was created a long time ago without any further steps.

    if you still need it then raise a new one.
    thanks

Production build 0.71.5 2024