PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Dynamically populate dropdown

  1. I'm trying to dynamically populate a dropdown box. Though I eventually hope to pull some values out of the WP DB, right now I can't even get the hooks tutorial working using the default values.

    In the dropdown, dynamic population is checked with a parameter name of "your_parameter".

    In functions.php, this code exists:

    add_filter('gform_field_value_your_parameter', 'my_custom_population_function');
    function my_custom_population_function($value){
        return 'boom';
    }

    And yet, on my form, the "Venue" dropdown (which the parameter is attached to) remains completely empty. What am I doing wrong?

    Posted 12 years ago on Tuesday April 24, 2012 | Permalink
  2. Can you send me a WP Admin login to rob@rocketgenius.com so I can take a look? Please reference this post in your email.

    Posted 12 years ago on Tuesday April 24, 2012 | Permalink
  3. You don't have any values in that drop down to pre-select, which is one way of pre-populating a drop down. The other is a bit more detailed and seems to be the way you will want to go, have you seen this:

    http://www.gravityhelp.com/documentation/page/Dynamically_Populating_Drop_Down_Fields

    Posted 12 years ago on Tuesday April 24, 2012 | Permalink
  4. I have not, I'll give it a try. Thanks!

    Posted 12 years ago on Tuesday April 24, 2012 | Permalink
  5. So I've been working away at it, but unfortunately pastie.org is down so I can't see what the completed code would look like in order to make comparisons against mine. Is there any way you could post the full code on pastebin or something for this tutorial?

    http://www.gravityhelp.com/documentation/page/Dynamically_Populating_Drop_Down_Fields

    Posted 12 years ago on Tuesday April 24, 2012 | Permalink
  6. Sorry, we'll have to wait until Pastie bounces back. The code isn't handy to simply re-post somewhere else. If it's going to be a long while then we'll try to find another place to host those snippets. Apologies for any inconvenience.

    Posted 12 years ago on Wednesday April 25, 2012 | Permalink
  7. Here you go: http://pastebin.com/QNqsScFf

    Posted 12 years ago on Wednesday April 25, 2012 | Permalink