The submit button redirects me to a wrong page, when I put something in $form['storage'] in the #submit or #validate handler of the form, and have clicked the 'preview' button

function clubmember_form(&$node, $form_state) {
  $form['#submit'][] = 'xxx_node_form_submit';
  $form['#validate'][] = 'xxx_node_form_validate';
  .....
}

function xxx_node_form_submit($form, &$form_state) {
    $form_state['storage']['test'] = true;
}

function xxx_node_form_validate($form, &$form_state) {
    $form_state['storage']['test'] = true;
}

How to reproduce using poll.module?

add to the function poll_form(&$node, $form_state) the folowing line

  $form['#submit'][] = 'poll_node_form_submit2';

and add the function

function poll_node_form_submit2($form, &$form_state) {
    $form_state['storage']['test'] = true;
}

now goto node/add/poll

fill in some values, click 'preview' and the click 'submit'
you are not at the newly created node but you are back at node/add/poll....

same happens when using the #validate handler

Comments

bwynants’s picture

I think page http://drupal.org/node/144132 has a clue why this happens

Note that if $form_state['storage'] is populated, $form_state['rebuild'] is automatically set to TRUE.

and

The 'rebuild' key overrides the 'redirect' key

but how can one use the 'storage' in node forms then?

dpearcefl’s picture

Is this still an issue using current Drupal 6?

Status: Active » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.