How to Dynamically Populate Drop Down Fields in Gravity Forms

Learn how to dynamically populate Drop Down fields in Gravity Forms with users, form entries, database tables, and more!

cover creative how to dynamically populate drop down fields in gravity forms

If you’ve ever dipped your toes into Gravity Forms before, chances are you’ve had a run in with the Drop Down field. They’re rockstars in the form-building world and their versatility makes it easy to display a list of choices for users interacting with your forms.

Creating a Drop Down field in Gravity Forms is simple enough. Just add the field, type in all of the choices you want to display, and you’re finished.

But what happens if you have a large dataset that you want to convert into choices? Or, what if you want to load your choices from somewhere else? Manually entering in a large list of choices can be cumbersome and difficult to maintain if it’s changing frequently.

Gravity Forms Populate Anything includes the ability to dynamically populate information from a number of different data objects into Drop Down fields. In this tutorial, we’ll explore some of the benefits of dynamic population, and review step-by-step how you can populate data from different object types.

Table of Contents

  1. Benefits of Dynamic Population
    1. Create a Personalized Experience for Users
    2. Advanced Search and Filtering
    3. Data Standardization
    4. Easy Database Access
  2. Object Types
    1. 1. Populate a List of Users
    2. 2. Filter Users by Role
    3. 3. Populate Entries from Another Form
    4. 4. Populate Data from a Custom Database Table
    5. 5. Populate Data from Google Sheets
    6. 6. Save Form Entries to Google Sheets
  3. How’d We Do?

Benefits of Dynamic Population

Create a Personalized Experience for Users

Dynamically populating Drop Down fields enables you to provide a personalized user experience. Instead of manually entering a static list of choices, you can populate options based on a previous selection, the user’s role, and many other filters. This ensures that users only see choices that are relevant to them, and makes interacting with the form a breeze.

Advanced Search and Filtering

When combined with Gravity Forms Advanced Select, you can populate large datasets and provide a way for users to quickly search and filter to find the data they need. This leads to a much improved and less overwhelming user experience.

Data Standardization

When you use the same data source across multiple forms, dynamically populating Drop Down choices ensures consistency. Any updates or additions to the data source get automatically applied to all forms that use the data source, saving you time and effort in maintaining multiple forms with similar options.

Easy Database Access

With Populate Anything, you can easily populate data directly from the WordPress database. This is especially handy when dealing with data that may be stored deep within a database table, and not easily accessible.

Interested in more about populating from databases? Check out our in-depth database population guide here.

Object Types

With Populate Anything, you can populate any of the following object types into Drop Down fields:

  • Posts
  • Users
  • Gravity Forms Entries
  • Google Sheets
  • Taxonomy Terms
  • Database data

For the purpose of this tutorial, we’ll focus on some common use cases using these object types, starting from easiest to the most challenging.

1. Populate a List of Users

Download the finished form here and import it to your site to get started right away.

Let’s start with a simple example. We’ll populate a Drop Down field with a list of all users on your WordPress site. Follow the steps below:

  1. With Populate Anything activated, add a new Drop Down field to your form called “Select User”.
  2. Under the General heading, check Populate choices dynamically.
  3. Choose User as the Type.
  4. Under the Choice Template heading, set the Value to User ID and the Label to Display Name.
  5. Save.

Your Drop Down field settings should look something like this:

gravity forms drop down field settings

To test out the user population settings, click Preview in the top right corner. You should see a list of all your user’s display names in the Users Drop Down field:

previewing gravity forms drop down fields

Now, when users access the form, the Drop Down will dynamically populate with the list of users from your site.

2. Filter Users by Role

Continuing with our previous example, let’s enhance our form by adding a filter. Filters can be especially convenient if you only need to display some options based on certain criteria.

Let’s say that we were making a form for just for students – or wizards in this example 🧙. We’ll filter the user list to only display users who have the Wizard role assigned to them.

  1. Open the form from above and click on the Select User field.
  2. Under General › Filters, click Add Filter Group.
  3. Set the filter to be: Role is Wizard. Replace “Wizard” with the role you want to display on your site.
  4. Save your form.

The updated filtering configuration should look like this:

filtering users by role in gravity forms

Click Preview in the top right corner to see the new list of users that will be shown. You should now only see users with the role you chose in the filter settings. Pretty neat!

3. Populate Entries from Another Form

Another powerful feature of GP Populate Anything is its ability to populate Drop Down fields with any form’s entries data.

Let’s say you have a job board that runs on WordPress. You may use one form to submit entries for each open role that you have. You could then take those form entries, and display them in a Drop Down field on a different form for the user to select which position they are applying to.

Here’s how you can set this up:

  1. With Populate Anything activated, add a new Drop Down field to your form called “Select Job”.
  2. Under the General heading, check Populate choices dynamically.
  3. Choose Gravity Forms entry as the Type.
  4. Under the Form header, select which form you’d like to use.
  5. Under the Choice Template heading, set the Value and Label fields to the fields that you’d like to display to the user.
    • In this example, I have a field called Job Title on my source form that I want the users to pick from.
  6. Save.
populating entries from another form into drop down fields

Try previewing the form to see a list of the form entries. In my case, I have a list of different job titles that I’ve submitted on my Job Postings form:

example output of populating entries into drop down fields with gravity forms

For more in-depth instructions on this particular use case, check out our job board tutorial here.

Check out Gravity Forms Advanced Select to create beautiful, accessible, and searchable Drop Down fields.

4. Populate Data from a Custom Database Table

One of the more advanced population options is the ability to populate data into a Drop Down field from any custom table in the WordPress database. This is especially useful when you need to populate data that other object types may not have access to.

Let’s say we have a custom database called airports.  Each airport has a unique city name, airport code, and country code. Here’s a sample of what the data looks like:

populating data from a custom database table with gravity forms

Let’s take a look at how we can populate a list of the airports in a Drop Down field for users to select from. Follow these steps:

  1. Open your form and add a new Drop Down field called “Choose Destination”.
  2. Make sure Populate choices dynamically is checked.
  3. Choose Database as the Type.
  4. Choose airports as the Table.
  5. Under the Choice Template section, set the Value to code and the Label to name.

Now, the Drop Down will dynamically populate with airports. We can also add a filter to only show airports in the list if their country code is US.

In the form settings, click Add Filter Group under the Filters header. We’ll set the filter to country is US:

populating from a database into gravity forms drop down fields

Here’s what the results look like on the frontend:

preview output of airport destinations in gravity forms dropdown

For more ideas and use cases around populating database table data, check out our in-depth tutorial here.

5. Populate Data from Google Sheets

Google Sheets is one of the most popular ways to store data in a spreadsheet format. Wouldn’t it be awesome if you could take a Google Sheet, and populate its data into a Drop Down field on your form? With a magical combination of Gravity Forms Google Sheets and Gravity Forms Populate Anything, you can!

For this example, we’ll use a spreadsheet that contains guest details for a wizarding convention. Here’s what my Google Sheet looks like:

populate data from google sheets into gravity forms drop down fields

Follow the steps below to populate a list of guests from the Google Sheet to Gravity Forms. Please note that both GF Google Sheets and Populate Anything are required:

  1. Follow the steps outlined here to connect your Google Account and add your spreadsheet.
  2. Open your form and add a new Drop Down field called “Choose Guest”.
  3. Make sure Populate choices dynamically is checked.
  4. Choose Google Sheet as the Type.
  5. Choose your Sheet’s name – in this case, it’s Wizard Guest Details.
  6. Under the Choice Template section, set the Value and Label to Guest Name.
the steps involved in populating from google sheets with drop down fields

The Drop Down should now be populated with a list of your guests!

preview output of drop down fields

6. Save Form Entries to Google Sheets

You can take it even further by exporting your form’s information back to Google Sheets once you’re all finished with the guest registration process. Check out our complete guide to two-way synchronization between Gravity Forms and Google Sheets below:

How’d We Do?

With so many different options to dynamically populate Drop Down fields, the possibilities are truly endless. We’d love to hear how you’re using dynamic Drop Down fields on your forms! Let us know in the comments below.

Comments

  1. Krishna
    Krishna October 14, 2024 at 8:41 am

    I have 4 forms, Registration, Graduated Year, Event and RSVP

    While registration, alumni will select the graduated year (Auto Populated form Graduated Year) (Admin) While creating the event they will select the allowed graduated batches (Multi-Select)(Auto Populated form Graduated Year) (Alumni) will rsvp using the form, i want to restrict the other batches who are not allowed, to submit the form.

    is this possible with gravity auto populate? How?

    Reply
    1. Scott Ryer
      Scott Ryer Staff October 28, 2024 at 11:24 am

      Hi Krishna,

      We followed up via email on this. We’re going to need some more information about your form setup to offer guidance on how this could work.

  2. Todd
    Todd April 25, 2024 at 10:22 am

    I have a dropdown list of US states and I want the user to select a state and then have another dropdown list dynamically populated with the counties from the selected state. To put it another way, I want my list of counties for each state filtered by the state selected in the first dropdown list. Is this plugin what I am looking for to achieve this or should I be considering something else? Thanks for your assistance.

    Reply
    1. Samuel Bassah
      Samuel Bassah Staff April 25, 2024 at 1:24 pm

      Hi Todd,

      This should be possible with the GP Populate Anything Perk filtering feature. However, you’ll need to have the data for the counties and their respective states stored somewhere to use Populate Anything to get the data from there to populate the fields. The data source can be Gravity Forms Entries, Custom Post Type, Google Sheets, or custom table in the database.

      Best,

    2. Abby
      Abby August 16, 2024 at 12:52 pm

      Did you find a solution to this? I’m trying to create a form where I want the choices in a dropdown to dynamically populate based on a previous dropdown selection.

  3. Marc Fuller
    Marc Fuller February 22, 2024 at 7:07 pm

    I’m using a database to populate the file. I’m trying to add a filter but the Add Filter Group button doesn’t perform any action. Any ideas?

    Reply
    1. Samuel Bassah
      Samuel Bassah Staff February 23, 2024 at 10:14 am

      Hi Marc,

      We’ll need to take a closer look at your setup to know exactly why it isn’t working for you. I’ll be sending emailing you so we can assist you further and get it working for you.

      Best,

  4. Charlie
    Charlie September 13, 2023 at 10:57 am

    One thing I was trying to do recently was populate a date field from an ACF date field. ACF stores the date as Ymd, which I needed to change. I couldn’t see any obvious way to achieve this with Populate Anything, so used a hook instead. Did I miss a way to do this with Populate Anything, or is this the best way to do this?

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.

Grab a bundle of free Gravity Forms plugins

Enter your email and receive our most popular free plugins and snippets, plus access to hundreds of others.

This field is for validation purposes and should be left unchanged.