How to Create Dynamic Field Choices

How to Auto-Populate Fields in WordPress Forms

Want to save time by having your form field choices automatically created and updated for you? WPForms makes it easy to include fields based on post-types or taxonomy. In this article, we’ll show you how to do that by creating dynamic field choices.

When to Use Dynamic Field Choices

Existing posts, pages, tags, and categories can provide valuable information for form submissions, allowing you to dynamically populate dropdowns, multiple choice, or checkbox fields.

You can easily ask users to select the appropriate option, without having to input it manually.

These are just a few of the reasons you might use dynamic field choices:

  • Ecommerce – If you have products listed in WooCommerce or other ecommerce, you can ask users to specify the item in question.
  • Real Estate – Users can submit a form with a question about a particular property or related to a specific agent.
  • Services – It will be more efficient for you when customers clarify which services are requested.
  • Frontend Post Submissions – Allow visitors to select from your blog post categories when submitting a post.

How to Use Dynamic Field Choices

The first thing you need to do is install and activate the WPForms plugin. Hereโ€™s a step by step guide on how to install a WordPress plugin.

Also, you’ll need to have a form created. See our tutorial on How to Create a Simple Contact Form as an example to get started.

WPForms is the best WordPress Form Builder plugin. Get it for free!

Now we’re ready to add a dynamic field choice!

Go to your form fields. Add a dropdown, multiple, or checkbox choice field and then click on it in the preview panel at right.

How to Create Dynamic Form Choices

In the Field Options panel at left, under Advanced Options, select the Dynamic Choice option. At this time, you can choose between a Post Type (Posts, Pages, or Custom Post Types) and Taxonomy (Categories or Tags).

In our example, we’re choosing the Custom Post Type of Products. When you view this form, all published products will be viewable. Users can select which item they are referring to in their form inquiry.

Products Dynamic Dropdown

Final Thoughts

Now youโ€™re all set! Youโ€™ve create a form with dynamic fields auto-populated with data from existing content within your website. Now, whenever your post type or taxonomies are updated, the form will be automatically updated along with them.

We hope this tutorial helped you create dynamic field choices in WordPress. You might also want to check out our guide on How to Create a Contact Form Popup in WordPress.

If you like this article, then please follow us on Facebook and Twitter for more free WordPress tutorials.

Using WordPress and want to get WPForms for free?

Enter the URL to your WordPress website to install.

Comments

  1. Hi, I wondered if it’s possible to set the post submission category as a default (so each submission auto categorizes, and the post will only show in sections filtered to that category).

    I’ve tried using the dynamic options, but you can’t select a default answer. I’ve also tried using a hidden field with a default setting and linking this through the Meta section on the Post Submission settings form. This way keeps coming back as uncategorized.

    1. Hi Simon,

      We don’t currently have an option for this, but I do agree it would be super useful. I’ve noted this in a feature request so that our team can consider adding an admin-determined category option for post submissions in the future.

      In case it helps in the meantime, you might consider modifying your site’s default post category. This is set to ‘Uncategorized’ when WordPress is installed, but can be changed to any category (under Settings > Writing — here’s a screenshot). I apologize that this isn’t an ideal workaround, but I hope this helps!

      And thanks for the suggestion ๐Ÿ™‚

  2. Hi,

    I’m looking to have the drop-down preselected to a choice based on a unique link. I want my users to press a “select” button under an image, then they are brought to the form at the bottom of the page with which ever choice they selected prefilled in the drop down.

    I already have the anchor figured out, now I just need to get the form to auto-populate their choice.

    Thanks

    1. Hi Nick,

      We don’t have a way to have the dropdown field preselected and auto-populate a choice based on a unique link but I’ve made a note on our feature request list so we can keep it on our radar! Thanks for the suggestion ๐Ÿ™‚

      1. Hi Jason.
        Yes, you can absolutely dynamically populate the dropdown field from the query strings in the page URL. For more details, please check this article on our site.
        I hope this helps.
        Have a good one ๐Ÿ™‚

  3. Hi, is it possible to pull usernames and/or email address in WP Forms from a SQL database? I’m looking for an easier way to import data than manually typing in over 300 employees.

    1. Hi Dan,

      We don’t have a way to do this right now, but I’ve made a note on our feature request list so we can keep it on our radar! Thanks for the suggestion ๐Ÿ™‚

      1. I am also very interested in being able to populate fields from an SQL database. I would like users to be able to select an item froman SQL database, brng it up, and view the record. This feature alone could be worth a pro membership. Being able to modify and resubmit as a new record absolutely

      2. Hi there!
        Currently, with WPForms you can dynamically populate Post Types or Taxonomies within the Dropdown, Multiple Choices or Checkbox fields. The option is available under Advanced Options of the fields.
        Unfortunately, we don’t have a built-in option to populate custom data from the database to the form fields. I do agree it would be super helpful, though. I’ve made a note of the feature request and we’ll keep it on our radar as we plan out our roadmap for the future.
        We appreciate your suggestion!
        Have a good one ๐Ÿ™‚

  4. I need a custom field to show from the selected dynamic post. Is this in the pipeline? Or is there a way I could hard code it? Thanks

    1. Hi Matt,

      I’m afraid I don’t quite understand what you’re trying to do so can you clarify a bit? Are you trying to get a field to conditionally appear based on the selection a user makes in a dynamic field?

  5. Hi, I have an array that I generated via a JSON request. Letโ€˜s say in the array are like 20 comma separated Names. Can I somehow map the array to a dropdown menu in WpForms?

    1. Hi Michael! Thanks for your comment.

      Currently, we do not have this feature in WPForms. I do agree it would be super helpful, though. I’ve made a note of the feature request and we’ll keep it on our radar as we plan out our roadmap for the future.

      Have a good one ๐Ÿ™‚

  6. Suppose I want to create a dropdown field populated by data from a database query and the default value pre-selected using programming code. This is for a form that is used to edit an existing database entry.

    So let’s say I have an entry for employee data and I have a field for which state they come from. So in the form, the dropdown options for State should be created automatically using custom code (without typing in states one by one) and the choice pre-selected by comparison with what’s in the database.

    In short, applying custom smart tags to dropdown or checkbox fields with programatically created choices.

    I have previously done this before using Ninja Forms, although I am having trouble figuring out how to do it with WP Forms. The documentation does not seem to address this situation.

  7. Hi,

    I want to create a form with 3 page break, first page has 2 dropdown (categories and products), and i need when user selects a category then in second dropdown shows products related with this category, not all products. I’m trying to do with “How to Exclude Posts, Pages or Categories From Dynamic Choices” docs but I can`t. Could you help me to do it simple or which document i need to review?

    Thanks.

  8. Hello!

    in the pro version. is there a way to filter auto populated list options (custom taxonomy, custom post type), either by interface or by code.
    It’s an important feature before we can buy this form.

    Thanks!

  9. Hello,

    Is it possible to pre-populate a form with user based information? For instance, when we start typing the name of a certain user, it populates the fields with the associated user and related data.

    1. Hi Hugo.
      Currently, we do not have a built-in feature to autocomplete fields with the user’s data. I do agree it would be super helpful, though. I’ve made a note of the feature request and we’ll keep it on our radar as we plan out our roadmap for the future.
      We have Smart Tags available for some of the user related information like User name, email, etc, but it can be used as a field default value or can be sent within the notification email. And this will take the current user information only.
      I apologize for any inconvenience!
      Have a good one ๐Ÿ™‚

  10. Is there a way to have a drop down menu remember the last value used? I need to have a form that returns to the same form after the ‘Submit’ button is pressed and there will be times that the default value of a new form will not be what we want. The use is for a unique type of inventory that will involve a few thousand items and while most fields on the form will stay as the default, one drop down menu will change for a significant number at a time. I can’t reset the default each time because multiple people will use the form and may be working on a different area. It’s starting to look like some custom code might be my option, but I thought I’d check to see if there are any other options. I haven’t purchased the Pro Version yet because I’m not sure WPForms can do what I need yet.

    Thank you,

    1. Hi LaMonte — I am not fully sure if this can be achieved with some small snippet but we would be happy to check it further for you! When you get a chance, please drop us a line in support so we can assist. Please elaborate your requirement a bit more when you contact them, try to explain what exactly you are trying to achieve here so they can try to find out some workaround if there is no quick code possible.

      If you have a WPForms license, you have access to our email support, so please submit a support ticket. Otherwise, we provide limited complimentary support in the WPForms Lite WordPress.org support forum.

      Thanks ๐Ÿ™‚

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.