Webform is a module which makes it easy to create forms in Drupal. Using Webform you can create sophisticated forms without the need for any coding.
When building forms to collect data be sure to avoid collecting sensitive information as outlined in the Information Security (IS) Policy & Procedures Manual
To get started select Webform from the Create Content menu.
At this point it looks like you are creating a regular page, as you don't see any options for adding form elements. That will come after. In this screen just set the title and the introductory text. You can also set a menu option for it, or wait and do that later.
After you save your page you will notice a tab titled Webform. Click this to begin adding form elements.
After completing the details for your first field you will be returned to the Webform tab to add additional fields.
After you add the field you will see the element details screen.
Pay particular attention to value you use for the field key. You will want these to be unique across all of the forms you create. If you plan on creating a number of forms you may want to prefix each field key with a short name of the form. For example "survey1_first_name". Only use lowercase and underscores in field keys.
If you want the field pre-filled with a default value then enter it here.
Enter any text as an aid to the person filling out the form.
There are a number of other options in the Element Details
You may have already made the field mandatory. This screen includes the options to make sue the entry is unique across all submissions, and to set a maximum length for the input.
These options control how the field is displayed on the form. Note that the default is to place the label above the field. If you want in to the left select "Inline" from the menu.
Tokens are code shorthand that will expand into a value when the form is displayed. These will not always be that useful. This example will pre-fill the e-mail field with the e-mail address of the person completing the form, but only if they have logged in to the site with their ONID. A more useful example might be the date token to fill in the current date.
There are many different types of components that can be used on a Webform, and all of these components can be configured to do different things, or appear different ways, according to what you need.
This section provides an overview of each different component type and the various features the component type consists of.
You can see that these options give you a lot of control over your form. For example you could use a "fieldset" to group form elements and optionally display an outline around them. You can also insert markup to add text or even images to your form.
Currently, the available components in Webform are as follows:
After you have added all of the fields to your form you can set some global settings for the form. Select the "Form Settings" tab in the Webform screen.
You may enter a confirmation message that will display once the form has been submitted.
Optionally you may want the page to redirect elsewhere once the form is submitted.
Limit how many times a person can submit the form.
You can disable the form to prevent people from submitting it, but still have it online. You can re-enable it again at any time.
Normally you will want anonymous and authenticated users to be able to submit the form, but it is possible to limit this to specific roles.
You may want to have a form available as a block so that you can place it in a region that will always display on certain pages. You may also want to change the text of the submit button.
To set where the results of the form will be sent, first click the E-mails tab on the Webform screen.
You have the option of sending all of the results to one or more addresses, or to an address based on the results of a form component. In our example I entered some e-mail addresses in the Affiliation field, so I am selecting it here.
After you click the "Add" button you will see the E-mail Settings screen.
Here you have options to customize the Subject, From address, and Form name, that will be sent in the e-mail.
This is a customizable template for the e-mail that will be sent with the results of the form submission.
By default the values of all of the form fields will be returned in the e-mail, but you can change that here.
To avoid getting a lot of spam submissions it is important to add a Captcha challenge. First click the "View" tab to view your form.
Then click the "Captcha" link and click "Place CAPTCHA here for untrusted users."
Note that this shows up on a lot of different places, but this is the only place you do this to get the Captcha on your form.
After clicking this you will get this next screen.
There are options for several types of Captcha, but we only want to use reCaptcha. Select this from the menu and then click Save.
You form is now protected from spam submissions. Note that logged in users will not see the Captcha, only anonymous users.
To control how the results of the form will appear, first click on the "E-mails" tab on the Webform screen.
You now have the option to edit the e-mail settings for the e-mails that are sent out after a Webform is created.
To create a new E-mail template, click on the word "Edit" in the Operations column of the E-mail that you want to change. Once the page has finished loading, you should see the Edit E-mail Settings screen. Scroll down the page until you see the "E-mail template" fieldset, shown below.
In this area, you can create the e-mail that will be sent out after the form is submitted.
The e-mail template field uses strings of characters and text, called tokens, to determine what information will be included in the e-mail that will be distributed upon submission of the Webform. These tokens are very powerful tools because they allow for a single e-mail template to use elements from your Webform to customize each email. This way every e-mail can be tailored to the individual that it is sent to.
Click on the words "Token values" to see the available token values.
Because using these tokens can be a little confusing, here are a few different examples of how to use the tokens. Each field has it's own unique field key, which is used by the tokens to differentiate between all of your different fields. For this example we will assume that I have a field whose title is "E-mail". The key for this field is "email", and the person submitting the Webform has entered email@example.com as their e-mail address.
If you put this in the template field:
then you will have this returned:
Or if you entered:
then the following would be returned:
The difference between these two entries is that when you use the %email[key] token you get what Drupal calls a formatted value, while you only are given the value of the field when you use the %value[key] token. The formatting refers to how Webform adds the title of the field followed by a colon and space before the value of the field. This way you can have things atomated to show their title the %email[key] token. Or, now you have the option to do something like put a person's name in the middle of a sentence with the %value[key] token.
The Webform module provides the ability to analyze the results of your webform submissions in a variety of different ways.
There even exists the ability to download the results in a comma-separated value (CSV) file format for use in a spreadsheet application such as Microsoft Excel or Open Office Calc.
So let’s take a moment to examine the analysis tools that are provided by the Webform module.
The Webform Manager is where you can find a list of all of the different webforms that have been created on your site.
To access the Webform Manager, go to Admin menu > Content management > Webforms.
On the Webform Manager, the Submissions link will take you to a simple list of all submissions for a given webform. To view the submission information for a particular webform, do the following:
The Webform module will provide you with an analysis of each and every field that users may (or may not) enter data in. To view this information, do the following:
The Webform module will provide a Table view of your webform, which displays all of the collected field data in their respective columns. To view the Table display, do the following:
The Webform module provides you the ability to download the results for a given webform into a comma-separated value (CSV) file, which can then be opened in a spreadsheet application such as Microsoft Excel or Open Office Calc. This will allow you to easily chart your results. To download your results, do the following:
Please note that while Webform gives you an option to download results into a Microsoft Excel format, this may not always work depending on the version of Microsoft Excel that you have on your computer. Your safest bet is to use the more generic CSV method, which will be automatically recognized by most spreadsheet applications.