I was recently involved in a project that required the use of Gravity Forms and a drop down field to display a list of posts from a custom post type for a job application system.
Most of the time in the past when I have needed to write custom field functionality for Gravity Forms, I have had the tendency to just use the standard fields available and then customise the functionality individually using hooks like ‘gform_field_content’ and ‘gform_field_input’.
This time around I felt like this idea could be beneficial to others and useful for me in a number of my other projects, so I decided to pluginify the field and make it available for others.
The field is called Gravity Forms Post Listing Field and allows you to add a dropdown field to your form (single select or multiselect) that will load a list of posts from either built in post types or custom post types. You can even group the posts by a custom taxonomy to give your drop down some order. That, coupled with developer hooks that allow you to customise some of the functionality of the field (including intercepting the post query to change the data that is displayed on the fly), makes it a powerful field to have in your arsenal of Gravity Form fields.
There are literally hundred of possible used for this field. Here are just a few:
- Multiple retail store locations as a custom post type – Advanced contact enquiry form (I am enquiring about store ‘x’)
- Job listings as a custom post type – Job application form (I am applying for position ‘x’)
- Donate to cause as a custom post type – Donation form (I want to donate to cause ‘x’)
- Interest groups as a custom post type – Enquiry form (I want to know more about group ‘x’)
- Contests as a custom post type – Voting form (I am voting for submission ‘x’ to win)
- Competitions as a custom post type – Enter form (I am entering competition ‘x’)
- Products as a custom post type (WooCommerce) – Enquiry form (I want to know more about product ‘x’)
If you interested in knowing more about this field, click here to be taken to CodeCanyon.