Modal Forms with Multistep Webform works perfectly.

I have now gotten it to Save Drafts correctly as well.

I'd like to know how to I load the form again with the Draft information already filled in?

If I go to node/ it works and the previously saved Draft is loaded.

When I try it with modal_forms/nojs/webform/ it just brings up a blank Webform to fill in again.

Any ideas?

Comments

cmcs’s picture

To answer my own question. Here is a quick note. Sorry for no patch yet.

I looked through the webform_node_view() function in the webform module and found some help.

I modified the function modal_forms_view_webform()

I added the following which loads the submission into $submission:

<?php
 
global $user;
  if ((
$node->webform['allow_draft'] || $node->webform['auto_save']) && $user->uid != 0)
  {
    if (
$draft_sid = _webform_fetch_draft_sid($node->nid, $user->uid))
    {
     
module_load_include('inc', 'webform', 'includes/webform.submissions');
     
$submission = webform_get_submission($node->nid, $draft_sid);
    }
  }
?>

Then I found which was calling drupal_get_form with no extra parameters:

<?php
return drupal_get_form('webform_client_form_' . $node->nid, $node, FALSE);
?>

And changed it to the below so that it now passes the $submission object:

<?php
return drupal_get_form('webform_client_form_' . $node->nid, $node, $submission);
?>

I also found a FALSE being sent to form builder args

<?php
$form_state
['build_info']['args'] = array($node, FALSE);
?>

Which I changed to include the $submission object:

<?php
$form_state
['build_info']['args'] = array($node, $submission);
?>