From 5c32f33425f1075ffb32ffc6a3d00c1519b6ea66 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Fri, 22 Oct 2010 00:35:35 +0000 Subject: - Patch #883454 by jhodgdon, ctmattice1: doc and examples for hook_form() are misleading/wrong. --- modules/node/node.api.php | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'modules/node/node.api.php') diff --git a/modules/node/node.api.php b/modules/node/node.api.php index a1725def8..253c2e354 100644 --- a/modules/node/node.api.php +++ b/modules/node/node.api.php @@ -1017,8 +1017,16 @@ function hook_prepare($node) { * Display a node editing form. * * This hook, implemented by node modules, is called to retrieve the form - * that is displayed when one attempts to "create/edit" an item. This form is - * displayed at the URI http://www.example.com/?q=node//nodetype. + * that is displayed to create or edit a node. This form is displayed at path + * node/add/[node type] or node/[node ID]/edit. + * + * The submit and preview buttons, administrative and display controls, and + * sections added by other modules (such as path settings, menu settings, + * comment settings, and fields managed by the Field UI module) are + * displayed automatically by the node module. This hook just needs to + * return the node title and form editing fields specific to the node type. + * + * For a detailed usage example, see node_example.module. * * @param $node * The node being added or edited. @@ -1026,21 +1034,21 @@ function hook_prepare($node) { * The form state array. * * @return - * An array containing the form elements to be displayed in the node - * edit form. - * - * The submit and preview buttons, taxonomy controls, and administrative - * accoutrements are displayed automatically by node.module. This hook - * needs to return the node title, the body text area, and fields - * specific to the node type. - * - * For a detailed usage example, see node_example.module. + * An array containing the title and any custom form elements to be displayed + * in the node editing form. * * @ingroup node_api_hooks */ function hook_form($node, &$form_state) { $type = node_type_get_type($node); + $form['title'] = array( + '#type' => 'textfield', + '#title' => check_plain($type->title_label), + '#default_value' => !empty($node->title) ? $node->title : '', + '#required' => TRUE, '#weight' => -5 + ); + $form['field1'] = array( '#type' => 'textfield', '#title' => t('Custom field'), -- cgit v1.2.3