form_execute_handlers

  1. drupal
    1. drupal6
    2. drupal7
Versionen
drupal6 – drupal7 form_execute_handlers($type, &$form, &$form_state)

A helper function used to execute custom validation and submission handlers for a given form. Button-specific handlers are checked first. If none exist, the function falls back to form-level handlers.

Übergabeparameter

$type The type of handler to execute. 'validate' or 'submit' are the defaults used by Form API.

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

$form_state A keyed array containing the current state of the form. If the user submitted the form by clicking a button with custom handler functions defined, those handlers will be stored here.

Verwandte Themen

▾ 3 functions call form_execute_handlers()

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.
node_form_submit_build_node in modules/node/node.pages.inc
Build a node by processing submitted form values and prepare for a form rebuild.
_form_validate in includes/form.inc
Performs validation on form elements. First ensures required fields are completed, #maxlength is not exceeded, and selected options were in the list of options given to the user. Then calls user-defined validators.

Code

includes/form.inc, line 758

<?php
function form_execute_handlers($type, &$form, &$form_state) {
  $return = FALSE;
  if (isset($form_state[$type . '_handlers'])) {
    $handlers = $form_state[$type . '_handlers'];
  }
  elseif (isset($form['#' . $type])) {
    $handlers = $form['#' . $type];
  }
  else {
    $handlers = array();
  }

  foreach ($handlers as $function) {
    if (function_exists($function)) {
      // Check to see if a previous _submit handler has set a batch, but 
      // make sure we do not react to a batch that is already being processed 
      // (for instance if a batch operation performs a drupal_execute()).
      if ($type == 'submit' && ($batch = & batch_get()) && !isset($batch['current_set'])) {
        // Some previous _submit handler has set a batch. We store the call
        // in a special 'control' batch set, for execution at the correct
        // time during the batch processing workflow.
        $batch['sets'][] = array('form_submit' => $function);
      }
      else {
        $function($form, $form_state);
      }
      $return = TRUE;
    }
  }
  return $return;
}
?>

Kommentare

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen