function merci_ahah_get_form in MERCI (Manage Equipment Reservations, Checkout and Inventory) 6.2
Does the very standard things that must be done in any normal callback. Used by each callback in this example module.
2 calls to merci_ahah_get_form()
- merci_choice_js in includes/
menu.inc - Menu callback for AHAH additions.
- merci_staff_update_name in modules/
merci_staff/ merci_staff.module - Menu callback for AHAH additions.
File
- ./
merci.module, line 1143 - MERCI - Managed Equipment Reservation Checkout and Inventory
Code
function merci_ahah_get_form() {
// The form is generated in an include file which we need to include manually.
include_once 'modules/node/node.pages.inc';
$form_state = array(
'storage' => NULL,
'submitted' => FALSE,
);
//$form_state = array('storage' => TRUE, 'submitted' => TRUE);
$form_build_id = $_POST['form_build_id'];
$form = form_get_cache($form_build_id, $form_state);
$args = $form['#parameters'];
$form_id = array_shift($args);
$form_state['post'] = $form['#post'] = $_POST;
// Enable the submit/validate handlers to determine whether AHAH-submittted.
$form_state['ahah_submission'] = TRUE;
$form['#programmed'] = $form['#redirect'] = FALSE;
// Stash original form action to avoid overwriting with drupal_rebuild_form().
$form_state['action'] = $form['#action'];
// Ripped off from drupal_process_form.
// We do the same except call validation.
$form = form_builder($form_id, $form, $form_state);
// We have to do this in order for the date_combo to be rebuilt properly.
$element = $form['field_merci_date'][0];
date_combo_validate($element, $form_state);
// Continue ripping off drupal_proecss_form
form_clean_id(NULL, TRUE);
$form_state['redirect'] = NULL;
form_execute_handlers('submit', $form, $form_state);
// We'll clear out the cached copies of the form and its stored data
// here, as we've finished with them. The in-memory copies are still
// here, though.
if (variable_get('cache', CACHE_DISABLED) == CACHE_DISABLED && !empty($form_state['values']['form_build_id'])) {
cache_clear_all('form_' . $form_state['values']['form_build_id'], 'cache_form');
cache_clear_all('storage_' . $form_state['values']['form_build_id'], 'cache_form');
}
// END ripping drupal_process_form.
$form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id);
// Clear any validation errors. Only the date field is validated so this will clear the error so it won't
// be outlined in red.
form_set_error(NULL, '', TRUE);
return array(
$form,
$form_state,
);
}