An Introduction to Entityforms Part 1

Watch An Introduction to Entityforms Part 2

Entityforms allows site builders to create survey style front-end forms without having to write any custom code. The form results are stored in the database and can be exported out. The module integrates with Rules which gives developers a lot of flexibility.

Entityforms is very similar to Webform, however it utilises Drupal’s Field API whereas Webform uses its own field system.

By leveraging Drupal’s Field API, you can use any module that implements its own field like Link, Date, Email and many more. Also, the user interface for adding fields to an Entityforms form is the same as adding fields to a content type, you will not have to learn a new user interface.

In this video, we’ll use Entityforms to create a complaints form for authenticated users.

Modules


drush dl entityform ctools views entity rules variable variable_email

Resources

Other modules mentioned:

Transcript

Entityforms allows site builders to create survey style front-end forms without having to write any custom code. The form results are stored in the database and can be exported out. The module integrates with Rules which gives developers a lot of flexibility.

Entityforms is very similar to Webform, however it utilises Drupal’s Field API whereas Webform uses its own field system.

By leveraging Drupal’s Field API, you can use any module that implements its own field like Link, Date, Email and many more. Also, the user interface for adding fields to an Entityforms form is the same as adding fields to a content type, you will not have to learn a new user interface.

In this video, we’ll use Entityforms to create a complaints form for authenticated users.

Getting Started

Setting up Entityforms is fairly simple, however you’ll have to download a few dependencies.

Before we begin, download and install the followings modules:

Entityforms, Views, Entity API, Rules, Variable and Variable Email.

Create a Form

Now that we have everything setup and ready to go, let’s create our complaints form. The form will be fairly simple it’ll have a name, message and department field.

Go to Structure, “Entityform Types” and click on “Add entityform type”. Enter “Complaints” into the name field. Scroll to the “Access settings” vertical tab and check the “authenticated user” checkbox within Roles.

This means that the form will only be accessible by authenticated users. Then, click on “Save entityform type”.

Attach Fields to Form

At this point we have just created the form, now we need to attach fields to the form. We’ll create three fields, name (text field), message (long text field) and department which will be a select field. Also, we’ll need to make all the fields mandatory.

First, let’s create the Name field. Enter Name into the label field, select Text from the “Field type” drop-down list and select “Text field” as the widget and then click on Save. Check “Required field” and click on “Save settings.

Next we’ll create the Department select field. Enter Department into the label field, select “List (text)” from the “Field type” drop-down list and select “Select list” as the widget, and then click on Save.

In the “Allowed values list” text-area you need to define the department field select options. For this video I will add the following, Accounts, Marketing and IT. Once you have defined your options, click on “Save field settings”.

Again, check the “Required field” checkbox and click on “Save settings”. And finally, let’s create the Message field.

Enter Message into the label field, select “Long text” from the “Field type” drop-down list and select “Text area (multiple rows)” as the widget. Click on Save. Again, “Required field” and click on “Save settings.

Form in Action

At this point, we have a working form. To find out the URL to the form, go to Structure, “Entityform Types” and click on “Submit Link”. Submit the form so that you have a submission. Form submissions can be viewed by going to Structure, “Entityform Types” and click on “Submissions”. From this page you can view, edit and delete submissions.

Email Notification

The final piece of functionality that we’ll look at in this video is how to setup email notifications. Entityforms ships with a sub-module called “Entityforms Notifications”. If you haven’t already, go and enable this module.

Entityforms Notifications module depends on Variable and Variable Email module. Make sure you have installed these modules.

Go to Structure, “Entityform Types” and click on “edit”. Click on the “Notifications settings” vertical tab. Select the “Email Entityform Admin” and “Email Entityform Submitter” option from “Submission rules”. Enter in some confirmation email text into “Email text.” Enter in email addresses into the “Notification emails” field.

Before we move on, the “Email Entityform Submitter” rule sends a confirmation email to the form submitter. The rule uses the email address that is attached to the user account.

The “Email Entityform Admin” rule sends a notification email to emails defined in the “Notification emails” field. Use this rule to notify specific users that a submission has been entered.

In part two of this series, we’ll look at submission, access and validation rules.

Leave a Comment

You have to agree to the comment policy.

This site uses Akismet to reduce spam. Learn how your comment data is processed.