Introduction to Entityforms Part 1

Update: This tutorial uses the 7.x-1.x version of Entityforms. The notification and validation settings have changed in 7.x-2.x, which is the stable version.

Entityforms module 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 is integrated with Rules (What’s Rules?) which gives developers a lot of flexibility.

Entityforms is very similar to Webform, however Entityforms 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 node, you will not have to learn a new user interface.

In this tutorial, we’ll use Entityforms to create a fake complaints form.

Getting Started

Setting up Entityforms is fairly simple, however you’ll have to download a few dependencies before you can install the module.

Before we begin, download and install the modules below.

You’ll also need to download the Email Field module if you’re following along with this tutorial as we’ll use this field on the form.

If you use Drush, run the following command:

drush dl entityform entity rules views ctools email variable_email variable

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, email, message and department field.

1. Go to Structure -> “Entityform Types” and click on “Add entityform type”.

2. Enter “Complaints” into the name field.

Fig 1.0

3. Scroll down to the “Access settings” vertical tab and check the “authenticated user” checkbox within Roles. Once complete, click on “Save entityform type”.

Note: The form will only be accessible for authenticated users.

Fig 1.1

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 four fields, name (text field), email (email field), message (long text field) and department (select field). Also, make sure all the fields are mandatory.

1. Create a Name field using the settings defined in Table 1-0.

Table 1-0. Define a Name field

Option Value
Label Name
Machine name field_name
Field type Text
Widget Text field

2. Create an Email field using the settings defined in Table 1-1.

Table 1-1. Define an Email field

Option Value
Label Email
Machine name field_email
Field type Email
Widget Text field

3. Create a Department field using the settings defined in Table 1-2.

Table 1-2. Define a Department field

Option Value
Label Department
Machine name field_department
Field type List (text)
Widget Select list

Copy and paste the text below into the “Allowed values list” text area when you configure this field.

Accounts|Accounts
Marketing|Marketing
Information|Information

Fig 1.2

4. Create a Message field using the settings defined in Table 1-3.

Table 1-3. Define a Message field

Option Value
Label Message
Machine name field_message
Field type Long text
Widget Text area (multiple rows)

Once all the fields have been created, the “Manage fields” page should look like the image below.

Fig 1.3

At this point, we have a working form. If you need to find the form URL, go to Structure -> “Entityform Types” (admin/structure/entityform_types) and click on “Submit Link”.

Fig 1.4

Form in Action

Login with a user account and go to the Complaints form at eform/submit/complaints and submit the form to make sure everything works.

Fig 1.5

View Submissions

Form submissions can be viewed by clicking on “Submissions” from the “Entityform Types” (admin/structure/entityform_types) page.

Fig 1.6

Email Notification

The final piece of functionality that we’ll look at in this tutorial 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.

Once you enable “Entityforms Notifications”, you’ll get an extra vertical tab option when you edit a form.

1. Go to Structure -> “Entityform Types” (admin/structure/entityform_types) and click on “edit” within the Complaints row.

2. Click on the “Notifications settings” vertical tab.

3. Select the “Email Entityform Admin” and “Email Entityform Submitter” option from the “Submission rules” field.

4. Enter in the confirmation email text into “Email text.”

5. Enter in email addresses into the “Notification emails” field.

Fig 1.7

Now if we submit a form, the submitter as well as any emails in the “Notification emails” should receive an email.

In part 2 of this series, we’ll look further into access and submission rules.

If you have any questions, please leave a comment.

30 thoughts on “Introduction to Entityforms Part 1”

  1. Great, I didnt know this module… till now πŸ™‚ I’ll invest my time in learning this module, definitely will be worth it!

  2. Thanks for posting this. I only knew of webform and I like most of its functionality. However, being able to use any available field type is powerful. Thanks for sharing!

  3. Thanks for the primer! I have a question: how can I allow another user (or role) to edit a submission they did not create?

    1. Did you install the Email module? (https://drupal.org/project/email)

      If you can’t see it in the “Field type” drop-down try clearing the site cache.

      > You’ll also need to download the Email Field module if you’re following along with this tutorial as we’ll use this field on the form.

  4. I’ve been looking at entity forms for a while and hoping I get the chance to use them but I haven’t had a use case that requires it yet.

    The bonus with webforms is that (in my opinion anyway), it’s easier for content editors/not techy people to use. Alongside the dependency on rules means you may have to give someone more access that you’re willing whereas with webform they can do the vast majority of the above while not giving access to other parts of the site.

    Entity forms is powerful, and full of features, but I don’t think it’s a replacement for webforms (not that you ever said such, just mentioning it).

    1. I agree, Webform is great for surveys style forms. If you want to give a client the ability to build lots of forms, then Webform is the right choice.

      Entityforms, on the other hand, is geared towards developers. The module is great for building forms that are not as dynamic as surveys style forms.

      From a developers standpoint, because an entityform is an entity you get integration with Views, Rules, Search API and many other modules out of the box.

      If you want clients to manage their own forms then give them Webform. If you’re a developer or site builder and you need to build a complex form, that a client won’t touch, then look at Entityforms.

      My 2 cents πŸ™‚

      1. Completely agree, but I’ve not come across a form that a client won’t want to edit in some way or another (even something as basic as where the results email is sent to) – It’d be great to use it, I’m just waiting for when I get the chance to.

  5. How can we export data (like csv, odt and more)? Maybe using Views VBO module?
    Second question is: How to build charts on submission results? Also using Views VBO with jgraph or google graphs module?

      1. I wasn’t aware about Charts Module and views tight integration, but I was wondering about it. Moreover I wasn’t aware about View Data Export… I think would be a slighty short straight developement! Thanks you very much for sharing thoughts πŸ™‚

  6. Hey,

    thanks for the nice introduction to Entityform. But for me theres one Question left. How do I show submitted content to visitors?
    A little hint would be nice πŸ™‚

      1. Yes I’m trying to do it with the Views Module but it will not work.
        If i create a View under Structure -> Views -> Entityforms (A list of all entityforms submissions), the System goves me a Error:

        Fehlermeldung Views cannot create normal menu items for paths with a % in them.

        What should the right path be? If I just delete the “%” theres still an error (Site not found)

  7. This module is so fabulous, I can imagine a million ways to use it, where I’ve been using webforms and they don’t quite fit… Curious, though, how you can allow users to submit an entityform, but not edit or delete their submission? There doesn’t seem to be a per-form setting. Is there a way to do this that’s more granular than using the Core all-or-nothing Permissions / Roles?

    1. No, you can only do that via roles and permissions. But if you find a module that gives you granular permissions let me know. πŸ™‚

    2. In this case I wonder you could set a Rule, using some condition, for example “if entity value for current user is not null” you trigger an action that could be a re-route to a sorry page

  8. Hi – great tutorial… but I have followed all your steps, installing all the modules you have mentioned and still do not see a “notifications tab”, so I am unable to test to see if my forms work.

    I do see the forms submitted within drupal under “submissions”, but wanting the form email instead (or as an addition) as I need a trail of all forms in email format.

    Any suggestions?

    1. This tutorial uses the 7.x-1.x version of Entityforms. You’re probably using the 7.x-2.x version, the notifications functionality has changed in 2.x.

  9. Notification and Validation Settings tabs even though I installed all the modules listed, even after clearing the cache. Any thought as to why this may be?

    1. This tutorial uses the 7.x-1.x version of Entityforms. You’re probably using the 7.x-2.x version, the notifications functionality has changed in 2.x.

  10. How can I submit an entity form wherein a specific user/role can approve or disapprove it?
    For example, you have a Leave Request form and the manager(role) can approve or disapprove the request.

    Is it possible? Thank you so much πŸ™‚

    1. The module doesn’t offer any type of approve/disapprove workflow. It’s beyond the scope of the module.

      Is it possible? Yes but you’ll have to develop the functionality yourself.

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.