I was seeing a couple of errors in the Drupal Webform module, and this page describes the fixes I used to eliminate them. This applies to version 3.x so if you’ve upgraded to 4 I doubt this is relevant anymore.
Notice : Undefined index: #webform_component in theme_webform_display_select() (line 507 in /myserverpath/sites/all/modules/webform/components/select.inc).
As described at http://drupal.org/node/1462986.
To fix this I found #webform_component in the theme_webform_display_select() function in modules/webform/components/select.inc and coded around it:
function theme_webform_display_select($variables) { $element = $variables['element']; if (isset($element['#webform_component'])) { $component = $element['#webform_component']; } else { $component = NULL; }
The second problem was the redirect issue caused by Drupal’s drupal_goto() function favoring its “destination” URL variable over the “sid” (submission ID) variable set by Webform when a form is submitted. When you visit a Drupal site for the first time, say http://mysite.com/survey, the URL gets a “destination” variable that points to the current page’s numerical node ID (like http://mysite.com/survey?destination=node/70) in the browser’s address bar. This is normal behavior by Drupal.
However, Drupal’s Webform allows you to redirect users to a “Thank you” template or other page after a form is submitted and uses a URL variable to indicate that this redirection should occur. If the webform happens to be the first page they visited on the site, the URL will also have the “destination” variable, which causes Drupal to send the user to the indicated node (the web form) instead of the form’s “Thank you” page. The form gets submitted, their response is appended to the database, and the confirmation email is sent if necessary, but the user is redirected back to the blank form instead of the “Thank you” page. This causes them to submit the form again because they received no confirmation message and think nothing happened.
To fix it, I adjusted webform.module in the webform installation in all our web sites…
At the end of function webform_client_form_submit():
$form_state['redirect'] = $redirect; // fix destination variable redirect problem // makes drupal ignore the ?destination=node/xx setting from here on unset($_GET['destination']); drupal_static_reset('drupal_get_destination'); drupal_get_destination();
I also adjusted the results display to get rid of an error message related to the overwritten destination:
function webform_webform_submission_actions($node, $submission) { $actions = array(); if (module_exists('print_pdf') && user_access('access PDF version')) { $actions['printpdf'] = array( 'title' => t('Download PDF'), 'href' => 'printpdf/' . $node->nid . '/submission/' . $submission->sid, // 'query' => $destination; 'query' => drupal_get_destination(), // added this ); }