You are here

function nodesymlinks_ahah_handler in NodeSymlinks 6

Menu callback for AHAH additions. Most of the code taken from core poll module.

See also

poll_choice_js()

1 string reference to 'nodesymlinks_ahah_handler'
nodesymlinks_menu in ./nodesymlinks.module
Implementation of hook_menu().

File

./nodesymlinks.inc, line 483

Code

function nodesymlinks_ahah_handler() {
  module_load_include('inc', 'node', 'node.pages');
  $form_state = array(
    'storage' => NULL,
    'submitted' => FALSE,
  );
  $form_build_id = $_POST['form_build_id'];

  // Get the form from the cache.
  $form = form_get_cache($form_build_id, $form_state);
  $args = $form['#parameters'];
  $form_id = array_shift($args);

  // We will run some of the submit handlers so we need to disable redirecting.
  $form['#redirect'] = FALSE;

  // We need to process the form, prepare for that by setting a few internals
  // variables.
  $form['#post'] = $_POST;
  $form['#programmed'] = FALSE;
  $form_state['post'] = $_POST;

  // Build, validate and if possible, submit the form.
  drupal_process_form($form_id, $form, $form_state);

  // This call recreates the form relying solely on the form_state that the
  // drupal_process_form set up.
  $form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id);

  // Render the new output.
  $subform = $form['menu']['nodesymlinks']['items'];
  $output = theme('status_messages') . drupal_render($subform);
  $GLOBALS['devel_shutdown'] = FALSE;
  drupal_json(array(
    'status' => TRUE,
    'data' => $output,
  ));
}