node forms redirected to wrong page after preview

bwynants - November 24, 2008 - 21:18
Project:Drupal
Version:6.x-dev
Component:forms system
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

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

#1

bwynants - November 28, 2008 - 14:34

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?

 
 

Drupal is a registered trademark of Dries Buytaert.