diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-10-22 00:35:35 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-10-22 00:35:35 +0000 |
commit | 5c32f33425f1075ffb32ffc6a3d00c1519b6ea66 (patch) | |
tree | 6e55165afbc6da16723c21098c86b237c7946698 /modules | |
parent | c6f106c8ed0c33135bc9f569f7b636e8b8ccc9b7 (diff) | |
download | brdo-5c32f33425f1075ffb32ffc6a3d00c1519b6ea66.tar.gz brdo-5c32f33425f1075ffb32ffc6a3d00c1519b6ea66.tar.bz2 |
- Patch #883454 by jhodgdon, ctmattice1: doc and examples for hook_form() are misleading/wrong.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/node/node.api.php | 30 |
1 files changed, 19 insertions, 11 deletions
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/<add|edit>/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'), |