Adding Forms to Your Site
On this page:
Using Webforms on Your Site
The Webform module lets you easily create a web form through which users can supply information. The Webform is often used for a Contact Us form, but could also be used for surveys, feedback or registration information.
You create the form page and then add form fields (components) with entry limits and validation options as well as instructions to users. Data returned through the form is stored in Drupal and is easily viewed for analysis or exported to Excel. Forms can also be configured to send you an email alert. And, forms may be saved as a block for use throughout your site, for example, to create a feedback form placed on multiple page types.
Creating a Webform
The form is created in two steps. The first is to create the page for the form. You’ll supply a name and optional description and set any page options you want. The second step is to create the fields which will be part of the form.
To Create a Form Page
- From the Administrator menu click Content, then +Add content.
- Click Webform.
- Add a Title.
- Add Body content you wish users to see. This is optional.
- Adjust any settings, e.g., to provide a menu link or to turn off comments.
- Click Save.
We recommend that you disable comments on the Webform content type. Go to Structure > Content types > Webform > Edit, then click on Comment settings and change the Default comment setting for new content to Closed.
Notice the Tabs at the top right.
The Edit tab displays information about the Form page (node). You are taken immediately to the Edit tab when you create a new Webform.
Adding Fields to the Web Form
Once you create the page to hold the form you will need to add fields. From the Edit overlay screen, click the Webform tab.
Notice that the Webform overlay has three sub areas – Form components, E-mails, and Form settings. We’ll look at each.
Creating the Fields or Form Components
The Form components area is where you will create the fields for your form.
To Add Fields
- Add the field name in the New component name box.
- Select a Type for the field display from the drop-down list.
Be sure to choose the appropriate Type. Some fields (e.g., time, number) have built in validation and some will offer the user widgets for easy data entry (e.g., date) See explanation of types below.
Textfield displays text on single line Textarea displays text on multiple lines Fieldset group fields together as a unit Hidden captures information but does not display Markup allows you to insert html and css Page break will force a page break within the form Select options lets you use radio buttons and check boxes - Click Add. You will see the Edit component overlay where you can adjust settings for this field.
Making Adjustments to the Field Settings
- Edit the field Label if you desire.
- Add a Default value (optional) which will display automatically. The user may change this.
- Add a Description to help the user enter data in this field.
Notice the use of a token. A token is a quick way of using some information the systsem knows such as site name, user name, or date. Here the token %profile[istdraft:profile_first_name] is used to add the person’s first name by default to save the user time.
- Add Validation options to ensure the user enters data (Mandatory) which no one else has entered (Unique). Restrict data to a Maxlength of characters.
- Set the maximum Width for this field (in characters).
- Add a Prefix or Postfix to be added to the field data.
- Set the field Label display to appear above or below the entry box.
- Check Disabled to add a unchangeable default value.
- Check Private to limit viewing of this field to those with permission.
Be sure to click Save component. Repeat this process for each field you need.
To see your form click the View tab or close the overlay screen.
You can return to the Edit and Webform tabs at any point to change the web form page or edit the fields in you form.
Setting up an E-mail Alert for a Submitted Form
You can set up email alerts to be sent when a form is submitted. Click the E-mails button to set up the recipient and what will be included in the email.
- Click Webform, then E-mails.
- Enter the recipient email address in the _Address_box.
- Click Add.
Make Adjustments to Email Settings
- Add additional recipients separated by commas, if necessary.
- For the E-mail subject, E-mail from address and E-mail from name enter a value or leave the default value.
- You can also use the value from any component of your form by choosing from the drop down list.
Make Edits to Email Message
- A default email message template is provided which you can edit. Once edited, you may return to the original default by selecting Default template from the drop down box.
- The template uses tokens. You may add additional tokens or text.
- The %email_values token will display any components checked in the Included Email Values area.
- Click Save e-mail settings.
Managing Form Settings
You can make several adjustments to how the form will operate from the Form settings overlay screen.
Add a Confirmation Message
- Click Webform, then Form settings.
- Use the edit box to create a custom Confirmation message.
- Add a redirect to Confirmation page (automatically created) to have this message appear on a new page instead of a display message. You may also create your own confirmation page and redirect to it.
- Click Save configuration when you are finished making changes.
Set Limits to Form Submission
- Click Limit to and a number to limit Total submissions. You may limit within a time range as well.
- Click Limit to and a number to limit User submissions. You may limit within a time range as well.
- You can also click Closed to stop submissions completely. You can re-open submissions at any time.
- In the Submission Access section, check the roles which you want to respond to the form, or uncheck the role(s) to prevent submission.
- Click Save configuration when you are finished making changes.
Set the text for submission button and other advanced settings:
- In the Advanced Settings section, enter new text in the Submit button text box to override the default Submit text.
- Click Available as block to make your form available to be placed on other pages as a block. You would then access the form on the Block overlay page.
- Click Save configuration when you are finished making changes.
Reviewing Submitted Data
On the overlay page for your web form, click the Results tab. This tab lets you view and download the data from your form submissions.
To View a List of All Submissions
- On the _Results_tab, click the Submissions button to see a list of all submission records.
- Click a column head to sort by that column.
- Click a name to see that person’s profile.
- For each record you may choose to view, edit or delete.
When you click View in the Operations column you will see a record which looks like this. If necessary you can Edit the response or Delete it.
To See a Simple Analysis of the Submissions
- On the Results tab, click Analysis.
- For each field you will see how many users entered information, how many left the field blank and the average length of the submissions for that field.
To See Field Data for Each Submission in a Table Format
- On the Results tab, click Table.
- For each submissions the data from each field will be displayed on a row. This display becomes less useful as the number of fields in your form grows in number.
To Download the Results from your Webform Submissions
- On the Results tab, click Download.
- Select the Export format, Delimited text or Microsoft Excel.
- Change the Delimited text format if required. In most cases you’ll want to leave this as is.
You have a number of options in the List Options, Components and Range sections.
SELECT LIST OPTIONS | for choosing among download list formats; in most cases you can leave the default |
INCLUDED EXPORT COMPONENTS | choose which fields to download |
DOWNLOAD RANGE OPTIONS | useful for selecting subsets of submission data to download, e.g., “Only the latest 50 submissions” or “Only new submissions since your last download”. |
To Clear All Submission Forms (all data)
- Click Results, then Clear. All of your data will be deleted.
- You will be presented with a warning message.
- Click the Clear button.
Be sure you have downloaded and saved your data if necessary before using Clear. This cannot be undone. Also note that any new submissions after a Clear will continue numbering from the last submission, and not begin again with the number 1.