You are here

function _sheetnode_google_js in Sheetnode 6

1 string reference to '_sheetnode_google_js'
sheetnode_google_menu in modules/sheetnode_google/sheetnode_google.module
Implementation of hook_menu().

File

modules/sheetnode_google/sheetnode_google.module, line 63

Code

function _sheetnode_google_js($callback) {
  $form_state = array(
    'submitted' => FALSE,
  );
  $form_build_id = $_POST['form_build_id'];

  // Add the new element to the stored form. Without adding the element to the
  // form, Drupal is not aware of this new elements existence and will not
  // process it. We retreive the cached form, add the element, and resave.
  $form = form_get_cache($form_build_id, $form_state);
  $render =& $callback($form, array(
    'values' => $_POST,
  ));
  form_set_cache($form_build_id, $form, $form_state);
  $form += array(
    '#post' => $_POST,
    '#programmed' => FALSE,
  );

  // Rebuild the form.
  $form = form_builder($_POST['form_id'], $form, $form_state);

  // Render the new output.
  print drupal_to_js(array(
    'data' => drupal_render($render),
    'status' => TRUE,
  ));
  exit;
}