0

I created a Ctools Multistep form. Its working fine. But when a user opens this multistep form in two tabs and fill the form fields simultaneously and submits it, both the submitted forms have same values for all the fields. Means both the submissions have same data.

When I have submitted this form in different browsers simultaneously, then both submissions have their own data.

I followed this tutorial to make Ctools Multistep form : http://www.xenyomedia.com/content/4-steps-form-multistep-form-ctools

I think, the problem is with $object_id = 'ctools_multistep';, because its same for both the forms in different tabs. Thats why it creates the same submissions for both forms.

Can anyone help me regarding this?

  • Whats the requirement? Why user trying to submit same form two times using different browser tabs? – ARUN Jun 15 '16 at 9:28
  • Hi Arun, client raised the bug for it. And for clarification, when user submit forms using two tabs of same browser, then this problem occure. – Pankaj Sachdeva Jun 15 '16 at 10:01
  • I don't think it is possible. Howmany google accounts we can login from a single browser? If you want to check concurrent user scenario use different browser or at-least try with normal and private browsing(incognito) mode. – ARUN Jun 16 '16 at 7:08
0

You have picked up correctly, the root cause for this issue is the object_id used by ctools multistep form, which is being generated per session. And for different tabs in a browser, we have the same session. So basically we need to figure out a way to get different object_id for each tab. This can be done in two ways: 1. Modify session mechanism to have a different session per tab. (Difficult) 2. Use query_parameters to handle two different requests. (For eg: time as id)

So, using 2nd way to solve our the problem: Get object_id dynamically.

$object_id = _module_get_object_id();

Ensure if id exists in URL, else return newly generated id.

function _module_get_object_id() {
  $params = drupal_get_query_parameters();
  if (isset($params['id'])) {
    return $params['id'];
  }
  else {
    $params['id'] = time();
    return $params['id'];
  }
}

and most important step, for adding id in URL as query parameter we need to add following code in the ctools_multistep_wizard_next function:

drupal_goto($form_state['redirect'][0], array('query' => array('id' => $form_state['object_id'])));

Reference: http://savaslabs.com/2015/06/23/implementing-ctools-multi-step-form-block.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.