Community Documentation

Upgrading from Webform 3.x to 4.x

Last updated July 9, 2012. Created by quicksketch on May 31, 2012.
Edited by colemanw. Log in to edit this page.

This page documents changes between the Webform 3.x version and the Webform 4.x version, including any information you need to know when upgrading from one version to the next.

The most important thing to keep in mind when upgrading from Webform 3.x to 4.x is that you cannot downgrade after update.php has been run, unless you restore a database backup created before the update.php run. Webform 4.x makes several database changes and downgrading after you have upgraded is not possible. Be sure to test your upgrade on a development server or localhost copy before upgrading your production server.

Changes between Webform 3.x and 4.x:

ALPHA1

ALPHA2

Detailed Change Instructions

Token System Replaced with D7-style Tokens

(issue) Webform previously used it's own custom token system to provide common tokens such as %title, %username, or %value[key]. In Webform 4.x, we use the token system provided by Drupal 7 core, which uses a format such as [node:title], [current-user:name], or [submission:values:key].

Most tokens will be upgraded for you, however some tokens do not have equivalents and no longer work. These include %post, %request, %cookie, and %session. The %get token (which maps to PHP's $_GET variable) has the equivalent token [current-page:query:key].

As mentioned, most tokens are upgraded for you in any configuration, default values, e-mail templates, etc. However tokens that are hard-coded within things such as node exports or webform-mail.tpl.php files will need to be changed manually. The complete map of replacements is as follows:

%username               [current-user:name]
%useremail              [current-user:mail]
%uid                    [current-user:uid]
%date                   [submission:date:long]
%ip_address             [current-user:ip-address]
%site                   [site:name]
%nid                    [node:nid]
%title                  [node:title]
%email_values           [submission:values]
%submission_url         [submission:url]
%sid                    [submission:sid]
%server[REQUEST_URI]    [current-page:url]
%get[$key]              [current-page:query:$key]
%email[$key]            [submission:values:$key]
%value[$key]            [submission:values:$key:nolabel]
%profile[$key]          [current-user:$key]

ALPHA2

The $submission->values variable structure changed

(issue) In Webform 3.x, values within the Webform $submission variable as retrieved by webform_get_submission() had a structure like the following:

Webform 3.x:

$submission->values[$cid]['value'][0] = 'string value';

However in 4.x, the superflous "value" key was eliminated to increase consistency in Webform's internal data structures during form processing.

Webform 4.x:

$submission->values[$cid][0] = 'string value';

Page status

No known problems

Log in to edit this page

About this page

Drupal version
Drupal 7.x
Audience
Programmers, Site builders
Level
Intermediate
Keywords
upgrading, webform

Site Building Guide

Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.
nobody click here