The Submit handlers use $form_state rather than returning urls section of the Drupal 5.x to 6.x FormAPI changes page has a superfluous line in the sample Drupal 6, $form_state['nid'] = $node->nid;, which (judging by core code usage) isn't needed, and thus only causes confusion for porters.

Comments

heather’s picture

Component: Developer Guide » Correction/Clarification

Changed the component to reflect the new component categorization. See http://drupal.org/node/301443

alan d.’s picture

The superfluous example is not a great one, but this does show how you would be able to pass extra information in chained submit handlers, or as the paragraph above states

This allows developers calling forms using drupal_execute() to properly handle to the results of a form's successful submission.

Maybe a more relevant example about this would be useful, or a comment about why this is set.

<?php
function my_form_submit($form, &$form_state) {
  // processing code goes here...

  // set the redirect
  $form_state['redirect'] = 'admin/my_page';

  // passing the new {node}.nid for use by drupal_execute or other submit handlers
  $form_state['nid'] = $node->nid;
}
?>

Personally, the only time I have wanted to use this is to allow a submit handler to redirect based on the results of the earlier submit handlers. I'm not sure why core uses nid and not the entire node object, see node_form_submit, but that's another topic.

MGParisi’s picture

Version: » 6.x-1.x-dev
Assigned: Unassigned » MGParisi
Status: Active » Fixed

Added PHP change (minor additional comment)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

mvk595’s picture

Version: 6.x-1.x-dev »