form_execute_handlers
Definition
form_execute_handlers($type, &$form, &$form_state)
includes/form.inc, line 740
Description
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.
Parameters
$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.
Related topics
| Name | Description |
|---|---|
| Form generation | Functions to enable the processing and display of HTML forms. |
Code
<?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 (drupal_function_exists($function)) {
if ($type == 'submit' && ($batch =& batch_get())) {
// 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;
}
?> 