ajax_get_form()Get a form submitted via #ajax during an AJAX callback.
This will load a form from the form cache used during AJAX operations. It pulls the form info from $_POST.
An array containing the $form and $form_state. Use the list() function to break these apart:
<?php
list($form, $form_state, $form_id, $form_build_id) = ajax_get_form();
?>
includes/ajax.inc, line 221
<?php
function ajax_get_form() {
$form_state = form_state_defaults();
$form_build_id = $_POST['form_build_id'];
// Get the form from the cache.
$form = form_get_cache($form_build_id, $form_state);
if (!$form) {
// If $form cannot be loaded from the cache, the form_build_id in $_POST
// must be invalid, which means that someone performed a POST request onto
// system/ajax without actually viewing the concerned form in the browser.
// This is likely a hacking attempt as it never happens under normal
// circumstances, so we just do nothing.
watchdog('ajax', 'Invalid form POST data.', array(), WATCHDOG_WARNING);
drupal_exit();
}
// Since some of the submit handlers are run, redirects need to be disabled.
$form_state['no_redirect'] = TRUE;
// The form needs to be processed; prepare for that by setting a few internal
// variables.
$form_state['input'] = $_POST;
$form_id = $form['#form_id'];
return array($form, $form_state, $form_id, $form_build_id);
}
?>