Webforms

From Stadm
Revision as of 15:36, 16 August 2012 by Zack (talk | contribs) (→‎Setup)
Jump to navigationJump to search


Out of the box, the Drupal Webform module provides a content type that builds a form on a page with several customizable elements including text, email and textarea for emailing content to a static email address configurable through the webform E-Mail settings in the Webform content type. Creating a contact form that sends emails to a variable address can be done using hook_form_alter.

Setup

  1. Webform should be enabled, and in its module configuration settings, Webform-enabled content types should be set to Webform. The Default Email Values in this menu can be left as they are.
  2. Once the module is enabled, you can add a new webform by going to admin->content->Add Content->Webform.
    1. On this page, you can set the title of the webform. The body field can be left blank.
    2. Click URL Path Settings below the body and type the page name and path you would like the form to appear on
  3. On the next page you can add components to your webform
    1. Components are things like textareas, file upload forms, date fields etc.
    2. These as well as their labels will appear on your form (except those with the type 'hidden')
    3. Content in hidden fields is accessible by the form application, but not viewable or editable by the user.
  4. For a contact form, you should add the following fields
    1. To (fieldset) - This is an non-editable field that displays the name of the recipient
    2. From (textfield) - This is where the user will type their own name
    3. Email (textfield) - This is where the user will type their own email
    4. Subject (textfield) - A subject can be added
    5. Message (textarea) - This is where the message goes
    6. To Email (hidden) - this will not be displayed on the form, but will retrieve the recipients email from the drupal database
  5. Click the E-Mails link below the Webform tabs
  6. Select "Component Value", and chose the field that you created for the recipients email ("To Email" in this example)
  7. Click Add
  8. The form is now set up. You can view it by navigating to the URL that you gave the form in step 2.