I fixed the deletion error and added the patch for showing the progress bar on new creation and now the submit button is redirecting to 'are you sure you want to delete this?'. Please help. Thanks!

Comments

brandy.brown’s picture

OK now magically I am not having this problem anymore. figures.

geek-merlin’s picture

Status: Active » Closed (cannot reproduce)

ok so close.

perarnet’s picture

Status: Closed (cannot reproduce) » Active

I am having the same issue under a different use case.

When editing a node showing all steps (node/9/edit?step=all) this error occurs if I add a imagefield image in one of the steps. Pressing next redirects to delete, but if I don't add a image, it doesn't.

This does not occur if I follow the normal steps.

geek-merlin’s picture

hello perarnet,

on your offending form ( node/9/edit?step=all ),
what buttons do you have, and in which order...?

perarnet’s picture

Previous and Next. Here's the html output:
<input type="submit" id="edit-previous" name="op" value="&lt; Last" class="form-submit" /><input type="submit" id="edit-next" name="op" value="Next &gt;" class="form-submit" />

geek-merlin’s picture

hmmm, which is of course a strange thing for a "step=all" form.
maybe we should change the logic to just leave the node "submit" button in that case as "prev" and "next" does not make too much sense.

can you try this patch?

perarnet’s picture

Thanks for the patch, it removed the previous and next button, and replaced with a submit button. I miss a delete button.

When I upload a image now, I am redirected to the first step of the multistep edit upon submit of the node, the correct redirect would be to display the node.

geek-merlin’s picture

Status: Active » Needs work

so this needs work... as i don't know when i get to it someone(tm) may feel free to volunteer...

perarnet’s picture

I erred in my last post. It was due to permission settings the delete button was removed. So the remaining problem is the redirect, not the buttons.

perarnet’s picture

Debugging the conditions of the error reveals that the problem occurs in the function
function multistep_get_step($type) {
....
}

When you upload (or remove) an image, the function gets called, and the step defined for the field is returned. It should naturally return 'all'. Not sure how to fix this.

geek-merlin’s picture

Title: Submit redirects to delete » Submit redirects to delete at or after image upload
Category: support » bug

@perarnet: thank you for sharing your findings.
can you figure out what happens in that function, i.e. which code path is taken and what is returned from which line?

here the code for reference:
http://drupalcode.org/project/multistep.git/blob/refs/heads/7.x-1.x:/mul...

and can you please re-state the problem step by step? i do not get if redirect happens
* immediately at upload
* or at submit after upload

perarnet’s picture

What happens when you upload an image there is a ajax call to the function multistep_get_step. The if statement at line 557 evaluates to true and the default step value for the image field (which in my case is step2) is returned. This affects the submit redirect for the node it seems.

The redirect happens upon node submit in other words.

geek-merlin’s picture

OK... so we should understand the D7 ajax mechanism thoroughly for this case:
http://drupal.org/node/752056

as i understand it the ajax call should only update the image field.
but it seems to mess with the submit handling in some obscure way...

perarnet’s picture

Title: Submit redirects to delete at or after image upload » Image upload changes redirection due to ajax

I just noticed when doing some debugging that the same issue is alive in the step process.
To recreate:
Create a node type 'multistep'
Add three steps, add image to second step. Upon upload the ajax function redirects "next" submit to node show, not step 3.

Changing title to reflect issue, as the bug issue has changed.

perarnet’s picture

Ok, I'm not sure if this solves all my headaches, but remove the following lines from the function multistep_field_attach_form(), and my initial tests work. I think this might be due to a string of fixes in core since the lines were introduced.

function multistep_field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode = NULL) {
[...]
  /* We need to remove #redirect to prevent redirection to the profile main page
   * @todo Change this to work for Profile2 as an included module.
  if (module_exists('content_profile') && is_content_profile($type)) {
    unset($form['#redirect']);
  }*/
-  if (arg(1) == 'ajax') {
-    return;
-  }
  $step = multistep_get_step($entity);
  if ($step == 'all') {
    // do not change submit buttons when no multistep
    return;
  }
[...]
geek-merlin’s picture

Title: Image upload changes redirection due to ajax » Submit redirects to delete at or after image upload
Status: Needs work » Needs review

the lines you shown are legacy so i cant tell but you sure may be right.
have no time to do testing but set to needs review.