Making forms redirect like they're supposed to even after complex hacking
wsf_action ben$ svn commit -m "that's drupal_goto, not drupal_go_to"
wsf_action ben$ svn commit -m "drupal_goto prevents form submission... how to make redirect work????"
wsf_action ben$ svn commit -m "despite not saying so, drupal_execute does return a redirect"
function wsf_action_combined_action_submit($form_id, &$form_values) {
$form_values['already_submitted'] = array(
'#type' => 'value',
'#value' => TRUE,
);
return drupal_execute('action_node_form', $form_values, $node);
}
It's back in the form_alter that we check for already submitted and give it the normal forms for processing, but it's this return statement-- rather than calling drupal_execute and calling return standalone-- that ensures we are redirected as node_form_submit intends.
Should have been able to intuit this, I guess, but I had to figure it out by working backward from drupal_execute:
http://api.drupal.org/api/function/drupal_execute/5
http://api.drupal.org/api/function/drupal_process_form/5
http://api.drupal.org/api/function/node_form_submit/5
Comments
Or to do it in a form_alter
$form['#redirect'] = 'your/path/here';
See http://api.drupal.org/api/file/developer/topics/forms_api_reference.html#redirect
Post new comment