drupal_get_form

Definition

drupal_get_form($form_id)
drupal/includes/form.inc, line 172

Description

Wrapper for drupal_build_form() for use when $form_state is not needed.

@see drupal_build_form()

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(), search_forms(), and user_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.

Return value

The form array.

Related topics

Namesort iconDescription
Form generationFunctions to enable the processing and display of HTML forms.

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);
}