Adding e-mail components

To assist with communication between form users and our conference organizers we will capture the e-mail address of registering speakers. The field will be a mandatory input and we will add a validation rule to ensure that no two speakers submit the same e-mail address.

It is quite possible that registering speakers are already registered users of our website, so we're going to default the Drupal user's e-mail address into this field. Many people have several e-mail addresses that they use for different purposes and it is possible that the registered user's e-mail address is not necessarily the preferred address that the registering speaker would like correspondence being addressed to. For this reason we will leave this field as editable.

How to do it...

Type e-mail address in the New component name textfield. Select e-mail in the TYPE drop-down selection list, check the box under MANDATORY and click on the Add operation button.

In order to pre-populate this field with a logged in user's e-mail address, we must enter the user e-mail address token %useremail in the Default value text box.

To ensure that no two registering speakers attempt to submit identical e-mail addresses we check the box next to Unique under the VALIDATION heading.

Click on Save component to create the component and return to the Form components overview page.

How it works...

While the form is being built for rendering, Webform will substitute the %useremail token with the e-mail address supplied when the user is registered on our site. The field will always be blank when the form user is not currently logged in. Notice that the user e-mail token is listed under the VALUE column of the components overview page.

There's more...

The e-mail component validates that e-mail addresses are correctly formed. It makes use of the same validation that the Drupal core system performs when users register on the site. This validation is not foolproof, however, because it does not verify that the specified e-mail server exists (that is, the bit that follows after the @ symbol in the submitted e-mail address), nor does it verify that the specified e-mail user (that is, the bit that precedes the @ symbol) exists on that e-mail server.

Viewing our progress

Lets see how the form looks so far by clicking on the View tab, shown as follows:

Viewing our progress

We should see that the node title and description that we entered when creating our Webform node appear at the top of the form. Our three components are listed underneath, followed by a form Submit button.

Okay, let's click on the Webform tab to continue adding components.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset