The function node_form() in node.pages.inc does not retrieve and pass additional user supplied arguments through to the invocation of hook_form for use by user supplied form building routines.

The node_form() function accepts the usual $form_state argument required for all form constructor routines, and it also requires an additional argument of $node. Both of these are passed to the hook_form() invocation, but additional arguments are not.

The hook_form invocation (actually performed by function node_invoke in node.module) will accept two additional arguments and pass these onto the custom form constructor function, so it should be a simple task to have the node_form() function collect these if they exist and pass them through.

At present, the custom form constructor function on hook_form() will get the $node and $form_state parameters, followed by two null arguments.

Allowing a custom module call to drupal_get_form() for a node type form to pass additional arguments through to the custom constructor will enable the form to be built specifically for the node in question. In particular, it will allow URL links such as "/node/add/my_type/value1/value2" or "/node/123/edit/value3/value4" to be useful in controlling the content presented to the user in the form.

The only workaround at present is to implement the functionality in a hook_form_alter() routine. This routine can examine the "#parameters" property of the the supplied $form to determine whether there were any additional parameters supplied to the drupal_get_form() function. If any are present, they will be in $form['#parameters'][3], and ...[4], etc. The form can then be modified before being rendered and displayed.

Comments

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.