For anyone who needs help with this, here’s my solution.
With the Gravity Forms hooks gform_pre_render
, gform_pre_validation
, gform_pre_submission_filter
and gform_admin_pre_render
I was able to populate the dropdown fields with dynamic data.
Despite this is not too user friendly, we can define specific CSS classes to have this done and avoid populate fields that we don’t want to.
- Take a look to the structure of the Form Object to see how the field types are called and how to target them on the next point.
- Check the how-to: Dynamically Populating Drop Down Fields
Basically what we do is create a function that renders the form. But first, as I mentioned above, to avoid populate the incorrect fields, we validate that is the correct field type (Important: with custom fields, the type
is custom_field
instead select
[as the tutorial describes]. To target custom fields of type dropdown/radio, set the type
to custom_field
and the field_type
to select
), and the correct CSS class.
Then, instead of using get_posts
, we use get_terms
to retrieve the terms.
Hope this helps someone.