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.

Help with dynamically populating drop down

  1. Hello, I'm new to GF and trying to figure out how to work with filters. I have some code that dynamically populates a drop down with only child taxonomies, and when that child is clicked will list all posts under that child taxonomy. The drop down is currently not made through GF, but I would like the drop down to match the look of the drop downs I created using GF so I think my choices are to use a filter to dynamically populate the GF dropdown, or apply the jquery/css to the existing dropdown to match the GF.

    I've been looking through the forum and the docs and trying the filter example for dynamically populating a drop down and I can't get it to work.

    I've created a basic form (id 3) with just a drop down field. I've checked the "Allow field to be populated dynamically" and added a parameter name of "dyn_test".

    In my functions I added your example code:
    'add_filter('gform_field_value_dyn_test', 'my_custom_population_function');
    function my_custom_population_function($value){
    return 'boom!';
    }'

    When I add the form to a page, it shows "Select an option" but then the drop down is empty. I've also added a single line text box, and it correctly shows "boom!" when the page loads.

    Can someone help me understand why it's not populating the drop down correctly? It's currently on a localhost, but I can try it on a live site if needed.

    I would like to figure this out, but another option I have is to apply jquery/css to my existing drop down to make it function the same as GF enhanced user interface. If that's easier, is there any documentation that shows how to do this? I've spent quite a bit of time reading through the docs and forum but can't figure it out.

    Thank you!

    Posted 12 years ago on Wednesday April 18, 2012 | Permalink
  2. There are two ways to populate a drop down field. The first way is pre-selecting a drop down option when the form is displayed (meaning pulling static choices you've already set in the drop down via the formbuilder). The second way is dynamically populating the options that are available in a select (aka drop down) field - this is the way I believe you are trying to achieve.

    There is a walkthrough on that here, have you seen this yet?

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

    Posted 12 years ago on Wednesday April 18, 2012 | Permalink
  3. Hi Rob,

    Thanks for your reply. Yes, I am trying to get the second method working. I did look at that walkthrough and tried it, but with no results so I thought I'd start with the easier tutorial from your site (the one in my first post).

    Neither are working, so I wanted to go with the more basic tutorial to get that working before getting more complex.

    As I mentioned, the above code is taken directly from your docs, and it is working for the single line text field, but NOT for the drop down (both are on the same form).

    Any ideas what I might be doing wrong with the drop down, or where I can begin looking to troubleshoot?

    Posted 12 years ago on Wednesday April 18, 2012 | Permalink
  4. At this point we'd need to see a form url that we can access and potentially WP Admin access to take a look at your current setup.

    Posted 12 years ago on Wednesday April 18, 2012 | Permalink
  5. I was not able to get this example to work, but I was finally able to get it to work using one of your other examples. Thank you.

    Posted 12 years ago on Monday June 11, 2012 | Permalink
  6. Right on, glad you got it working!

    Posted 12 years ago on Tuesday June 12, 2012 | Permalink

This topic has been resolved and has been closed to new replies.