NULL, 'submitted' => FALSE); $form_build_id = $_POST['form_build_id']; // Step #4. $form = form_get_cache($form_build_id, $form_state); // Preparing for #5. $args = $form['#parameters']; $form_id = array_shift($args); $form_state['post'] = $form['#post'] = $_POST; $form['#programmed'] = $form['#redirect'] = FALSE; // Step #5. drupal_process_form($form_id, $form, $form_state); // Step #6 and #7 and #8. $form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id); // Do whatever we need here for Step #9. drupal_set_message(t('media_ahah_formatter_load can add anything here (if necessary).')); // Step #10: Output any drupal messages and the new form. $media_tabs = $form[$field]['media']['media_tabs']; $output = theme('status_messages') . drupal_render($media_tabs); // Ensure any changes to Drupal.settings js are preserved. $javascript = drupal_add_js(NULL, NULL, 'header'); // Final rendering callback. drupal_json(array( 'status' => TRUE, 'data' => $output, 'settings' => call_user_func_array('array_merge_recursive', $javascript['setting']), )); } /** * TODO: Document */ function media_ahah_metadata_ahah() { // The form is generated in an include file which we need to include manually. include_once 'modules/node/node.pages.inc'; // We're starting in step #3, preparing for #4. $form_state = array('storage' => NULL, 'submitted' => FALSE); $form_build_id = $_POST['form_build_id']; // Step #4. $form = form_get_cache($form_build_id, $form_state); // Preparing for #5. $args = $form['#parameters']; $form_id = array_shift($args); $form_state['post'] = $form['#post'] = $_POST; $form['#programmed'] = $form['#redirect'] = FALSE; // Step #5. drupal_process_form($form_id, $form, $form_state); // Step #6 and #7 and #8. $form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id); // Do whatever we need here for Step #9. drupal_set_message(t('final submission: media_ahah_metadata_ahah can do something here, maybe display a new add file form?')); // Step #10: Output any drupal messages and the new form. $media_tabs = $form[$field]['media']['media_tabs']; $output = theme('status_messages') . drupal_render($media_tabs); // Ensure any changes to Drupal.settings js are preserved. $javascript = drupal_add_js(NULL, NULL, 'header'); // Final rendering callback. drupal_json(array( 'status' => TRUE, 'data' => $output, 'settings' => call_user_func_array('array_merge_recursive', $javascript['setting']), )); }