Exploring Gravity Forms

June 10, 2019

Introduction

Gravity Forms is a popular plugin for WordPress websites, which enables us to build advanced forms with ease. This plugin provides many useful features and can easily be extended to integrate with custom website. This blog will demonstrate some of my favourite features of Gravity Forms

3 Favourite Features

  1. Validation – Validation is an important step in the process of collecting data. Before a user submits a form we typically perform a check to assess whether or not the supplied information is accurate. If there are problems with the information submitted then the user is instructed to correct the invalid fields, otherwise the form is submitted successfully. Gravity Forms offers basic validation with most field types. For instance, you can specify whether a field is required or not through the admin screen of a given form. Custom validation can also be achieved through Gravity Forms, because the plugin allows developers to target individual fields during the validation process where we can inject code containing our custom validation rules. For example, if we want to prevent users from providing an email address that contains the word “admin” we can simply target the email field of a given form and perform our custom validation. Gravity Forms can also accommodate complex scenarios where the validation of a given field is dependent on the value of other fields. For instance, when providing an address, a postal code of “M4R 1B1” is valid in Canada, but not in the United States. Overall, the flexibility of the plugin when handling validation makes it a very useful feature.
  2. Conditional Logic – When designing a form, it is important to consider both the data that needs to be collected and the presentation of the form. Obviously a user is more likely to complete a simple form with a few fields compared to a complex form with many fields. However, it is not uncommon that a form requires many fields, which will negatively impact the presentation and ultimately the conversion rate. Fortunately, Gravity Forms provides a useful feature to help address this problem by allowing us to conditionally display fields. This is called “Conditional Logic” and it can be enabled in the admin page of a Form under the the Advanced tab of a given Field. This feature allows you to specify whether the target field should be displayed or hidden based on the value of one more fields. As a result, we can simplify the presentation of a complex form by only showing fields that are relevant.
  3. Admin Customization – Recently I discovered that Gravity Forms allows for customization of the admin screen, which has proven useful for helping clients to better manage their forms independently over the long term. For instance, when configuring a field, Gravity Forms organizes the settings into the following three tabs:  General, Appearance, and Advanced. The plugin provides a way for developers to extend the functionality of each of these tabs for a given field type. This feature could be beneficial for many scenarios, but recently I found it useful for integrating Gravity Forms with a 3rd party software. The challenge was that the data from Gravity Forms had to be organized in a certain way to communicate with the 3rd party software. This affected how we handled dropdown fields with an option for “Other”. Typically, if a user selects “Other” from a dropdown we display an additional field where the user can specify a value, but in our case we needed to submit all the data as one field to the 3rd party software. Our solution was to add an admin input to each dropdown field, which was used to indicate what field value would substitute the “Other” option. While the scenario I just described may seem highly unusual, the point is to demonstrate that the admin screen can be customized, which is a nice feature that may prove useful to you.

Conclusion

In summary, Gravity Forms is a great plugin that provides a lot of value right out of the box and can even help solve complex problems by providing a framework that it easily customizable.