function tripal_core_ahah_prepare_form
1.x tripal_core_ahah.api.inc | tripal_core_ahah_prepare_form(&$form_state = array()) |
This function simply gets the posted form ID, builds the form and retrieves the specified element. This function should be called in an AHAH callback function to retrieve the form
See http://tripal.info/documentation/ahah_api for example usage
@returns A Drupal form array. If no form is available then FALSE is returned
Related topics
16 calls to tripal_core_ahah_prepare_form()
- tripal_ajax_db_edit in tripal_db/
includes/ tripal_db.admin.inc - tripal_analysis_property_add in tripal_analysis/
includes/ tripal_analysis.form.inc - tripal_analysis_property_delete in tripal_analysis/
includes/ tripal_analysis.form.inc - tripal_contact_property_add in tripal_contact/
includes/ tripal_contact.form.inc - tripal_contact_property_delete in tripal_contact/
includes/ tripal_contact.form.inc
File
- tripal_core/
api/ tripal_core_ahah.api.inc, line 51 - The Tripal AJAX/AHAH API
Code
function tripal_core_ahah_prepare_form(&$form_state = array()) {
// Retrieve the form from the cache
$form_state['storage'] = NULL;
$form_build_id = filter_xss($_POST['form_build_id']);
if (!$form_build_id) {
return FALSE;
}
$form = form_get_cache($form_build_id, $form_state);
// Preparing to process the form
$args = $form['#parameters'];
if (!is_array($args)) {
// if there is no form #parameters as an array then the form was not built property
return FALSE;
}
$form_id = array_shift($args);
$form_state['post'] = $form['#post'] = $_POST;
$form['#programmed'] = $form['#redirect'] = FALSE;
// we don't want to submit the form or have required fields validated on
// an ahah callback.
$form_state['submitted'] = TRUE;
$form['#validate'] = NULL;
$form['#submit'] = NULL;
$form_state['submit_handlers'] = NULL;
$form_state['validate_handlers'] = NULL;
tripal_core_ahah_form_element_disable_validation($form);
// Sets the form_state so that the validate and submit handlers can tell
// when the form is submitted via AHAH
$form_state['ahah_submission'] = TRUE;
// Process the form with drupal_process_form. This function calls the submit
// handlers, which put whatever was worthy of keeping into $form_state.
drupal_process_form($form_id, $form, $form_state);
// You call drupal_rebuild_form which destroys $_POST.
// The form generator function is called and creates the form again but since
// it knows to use $form_state, the form will be different.
// The new form gets cached and processed again, but because $_POST is
// destroyed, the submit handlers will not be called again.
$form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id);
return $form;
}