Working with Default Values

Last updated on
30 April 2025

Webform allows several special values to be used as defaults when configuring a component. The special placeholders are commonly called tokens. The tokens Webform supports include:

%username
%useremail
%site
%date
%server[key]
%session[key]
%get[key]
%post[key]
%request[key]
%profile[key]

Webform 7.x-4.x and later branches use the Token module.

Webform 7.x-3.x and prior branches do not use the Token module for its replacements, so Webform's tokens may vary from tokens used in other modules. However, you can use the Webform Patched module to use Token module tokens.

Sections

Populating a Field with User Data

Webform includes several tokens that contain user data such as %username and %useremail. In addition, Webform supports any field added through the core profile module. For example, if you had profile fields setup for "First Name" and "Last Name" you could set these values to be the default values for a Webform component.

When setting up the profile fields at Administer->User management->Profiles (admin/user/profile), take care to remember the "Form name" value, as this will be needed when configuring the default value of Webform components that will contain user information.

Configuring a profile field
Setting up a profile field at admin/user/profile/add/textfield. Note the "Form name" value is set to "profile_first_name"

After checking the configuration of a profile field, you can use the profile Form name as the default value in a Webform component.

Configuring a Webform component
When configuring a Webform component, use the Profile Form name in the special %profile[form_name] token.

If the current user has filled out the First name profile field, their name will automatically be used as the default value when filling out the webform.

Setting Default Values from the URL (7.x-3 and earlier)

The %get[key] supported by Webform allows form values to be populated from the URL.

Configuring a Webform component
Setting the default values of a component to use a %get[key] value.

The default value populated from the URL
The default value of the field populated from the URL.

Setting Default Values from the URL (7.x-4)

To set the default values of a component to use either:

Help improve this page

Page status: Not set

You can: