diff --git a/autosave.module b/autosave.module index 12704cb..ac4977e 100644 --- a/autosave.module +++ b/autosave.module @@ -275,6 +275,7 @@ function autosave_restore($form_id, $timestamp) { $record = autosave_get_autosaved_form($form_id, $timestamp, $user->uid); if ($record) { + $form_state = unserialize($record->serialized); // We need to extract and reuse any additional page arguments that the // original form may have. That's especially true for, say, a node form, // which needs the node object passed in as well. @@ -283,13 +284,6 @@ function autosave_restore($form_id, $timestamp) { require_once DRUPAL_ROOT . '/' . $menu_item['include_file']; $form_state['build_info']['files'][] = $menu_item['include_file']; } - $form_state['input'] = unserialize($record->serialized); - - // Restore form arguments. - if (!empty($record->args)) { - $args = unserialize($record->args); - $form_state['build_info']['args'] = $args; - } // Disable the "this form has already been submitted" nonsense by making // Drupal think the form is being rebuilt as part of a multi-step form. @@ -380,11 +374,10 @@ function autosave_save() { $prevent_autosave = FALSE; drupal_alter('autosave_prevent', $prevent_autosave); - $path = $_POST['autosave_form_path']; - $form_id = $_POST['form_id']; - // Not all variables need to be serialized. - unset($_POST['autosave_form_path'], $_POST['op'], $_POST['form_build_id']); - $serialized = serialize($_POST); + list($form, $form_state) = ajax_get_form(); + $path = $form_state['input']['autosave_form_path']; + $form_id = $form_state['input']['form_id']; + $serialized = serialize($form_state); if (!$prevent_autosave) { // Currently, each user can have only one autosave form at a particular path.