By default, Gravity Forms provides a stock dropdown field. The values of this field are static and, normally, you would type them in or copy/paste in bulk.
That’s all great but what if you want to set the values of the dropdown dynamically? Below is how you do it:
- Define the classes of the dropdown fields that you want to accept the dynamic fields
- Check that the type of the current fields is “select” and its class is matches one of the classes defined above
- Compile an array of the dynamic values and save it in the $field[‘choices’] array element
This example uses all the published entries of the “partners” custom post type as values for the dropdown.