You are here

function drupal_submit_form in Drupal 5

Same name and namespace in other branches
  1. 4 includes/form.inc \drupal_submit_form()

Processes user-submitted form data from a global variable using the submit functions defined in a structured form array.

Parameters

$form_id: A unique string identifying the form for validation, submission, theming, and hook_form_alter functions.

$form: An associative array containing the structure of the form.

Return value

A string containing the path of the page to display when processing is complete.

Related topics

1 call to drupal_submit_form()
drupal_process_form in includes/form.inc
This function is the heart of form API. The form gets built, validated and in appropriate cases, submitted.

File

includes/form.inc, line 417

Code

function drupal_submit_form($form_id, $form) {
  global $form_values;
  $default_args = array(
    $form_id,
    &$form_values,
  );
  $submitted = FALSE;
  $goto = NULL;
  if (isset($form['#submit'])) {
    foreach ($form['#submit'] as $function => $args) {
      if (function_exists($function)) {
        $args = array_merge($default_args, (array) $args);

        // Since we can only redirect to one page, only the last redirect
        // will work.
        $redirect = call_user_func_array($function, $args);
        $submitted = TRUE;
        if (isset($redirect)) {
          $goto = $redirect;
        }
      }
    }
  }
  return $goto;
}