function drupal_get_form

7.x form.inc drupal_get_form($form_id)
6.x form.inc drupal_get_form($form_id)

Returns a renderable form array for a given form ID.

This function should be used instead of drupal_build_form() when $form_state is not needed (i.e., when initially rendering the form) and is often used as a menu callback.

Parameters

$form_id: The unique string identifying the desired form. If a function with that name exists, it is called to build the form array. Modules that need to generate the same form (or very similar forms) using different $form_ids can implement hook_forms(), which maps different $form_id values to the proper form constructor function. Examples may be found in node_forms(), and search_forms().

...: Any additional arguments are passed on to the functions called by drupal_get_form(), including the unique form constructor function. For example, the node_edit form requires that a node object is passed in here when it is called. These are available to implementations of hook_form_alter() and hook_form_FORM_ID_alter() as the array $form_state['build_info']['args'].

Return value

The form array.

See also

drupal_build_form()

Related topics

47 calls to drupal_get_form()
authorize.php in drupal-7.x/authorize.php
Administrative script for running authorized file operations.
block_admin_display in drupal-7.x/modules/block/block.admin.inc
Menu callback for admin/structure/block.
book_outline in drupal-7.x/modules/book/book.pages.inc
Menu callback: Shows the outline form for a single node.
comment_admin in drupal-7.x/modules/comment/comment.admin.inc
Menu callback; present an administrative comment listing.
comment_confirm_delete_page in drupal-7.x/modules/comment/comment.admin.inc
Page callback for comment deletions.

... See full list

32 string references to 'drupal_get_form'
aggregator_menu in drupal-7.x/modules/aggregator/aggregator.module
Implements hook_menu().
ajax_forms_test_menu in drupal-7.x/modules/simpletest/tests/ajax_forms_test.module
Implements hook_menu().
batch_test_menu in drupal-7.x/modules/simpletest/tests/batch_test.module
Implement hook_menu().
block_menu in drupal-7.x/modules/block/block.module
Implements hook_menu().
book_menu in drupal-7.x/modules/book/book.module
Implements hook_menu().

... See full list

File

drupal-7.x/includes/form.inc, line 122
Functions for form and batch generation and processing.

Code

function drupal_get_form($form_id) {
  $form_state = array();

  $args = func_get_args();
  // Remove $form_id from the arguments.
  array_shift($args);
  $form_state['build_info']['args'] = $args;

  return drupal_build_form($form_id, $form_state);
}