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.

List Field Drop Down Option

  1. Imaginate
    Member

    I am trying to use the list field and make one of the columns a drop down. I've read a few topics on this, but I still can't quite get it to work. Perhaps you could help find where I've made a wrong turn.

    Here's what I've done:
    I created a form (Form ID 1), I then created a list field (Field ID 10) that has 3 columns (First Name, Last Name, Status). I would like the 3rd column ("Status") to be a drop down. I then created a drop down field (Field ID 11) with 4 statuses.

    I found a post that had this code to add to the functions.php file. http://pastie.org/3330873

    So I add this to the top:

    $gf_vars = array();
    $gf_vars['form_id'] = 1; // the form ID
    $gf_vars['dropdown'] = 11; // the field ID of the drop down form you will populate
    $gf_vars['list'] = 10; // the field ID of the list field from which the values should be pulled
    $gf_vars['column_name'] = 'Status'; // the column name of the column to retrieve the values

    But it is still not working. Am I missing something?

    Thanks

    Posted 7 years ago on Monday June 25, 2012 | Permalink
  2. Do you have a link to your form and can you paste your full code in a pastie and what was the post you took this from?

    Posted 7 years ago on Friday July 6, 2012 | Permalink
  3. Imaginate
    Member

    Here is the post that I got the code from:
    http://www.gravityhelp.com/forums/topic/populate-dropdown-with-list-field

    It's on a my clients private site, so can't provide a link, but I've provided the steps I did above.

    Shouldn't this work? or am I missing something?

    Posted 7 years ago on Friday July 6, 2012 | Permalink
  4. Hi Imaginate,

    Here is an example where I've updated the first column of my field to use a drop down.

    http://grab.by/eNVE

    And here is the code that powers it:

    http://pastie.org/4268627

    You will need to update the "83" in the filter name "gform_column_input_1_83_1" to your field ID. You can set the values which will populate your drop down by update this array in the code: "array('Blog', 'Personal Website', 'Company Website', 'Other')" with your own values.

    Let me know what questions you have based on this. :)

    Posted 7 years ago on Monday July 16, 2012 | Permalink
  5. This is really great. David, if I wanted to make this populate with custom post type titles, what am I doing wrong here: http://chopapp.com/#rkpfl3n7

    Or do you need to use jquery and ajax?

    Thanks

    Posted 7 years ago on Tuesday November 6, 2012 | Permalink
  6. @iphoenix, on line 7:

    [php]
    $posts = query_posts( array( 'post_type' => 'post_type' ) );

    The second "post_type" should be the name of your custom post type. It could be "post" or "page" or "autos" or "reviews". Are you using it literally as you posted in your code example?

    You do not need to use AJAX or jQuery.

    Posted 7 years ago on Thursday December 20, 2012 | Permalink
  7. Yes, I filled in my post type in the second part, but a drop down does not show up with the populated values.

    http://pastie.org/5650665#14

    Posted 7 years ago on Tuesday January 8, 2013 | Permalink
  8. Can you put on pastie.org how you registered your custom post type?

    Or can you use phpMyAdmin or something similar with a query to show how you would get the custom posts out of the database directly, just to be sure we're calling them by the correct name?

    I would be sure to get the custom posts returned properly first, in some function, then try to add those to the drop down in your form.

    Posted 7 years ago on Wednesday January 9, 2013 | Permalink
  9. Sure! Sorry it took so long:

    http://pastie.org/5689585

    Posted 7 years ago on Tuesday January 15, 2013 | Permalink
  10. @iphoenix, in this code http://pastie.org/5650665#7 can you dump the $post object and see what it contains? We need to see where the disconnect is.

    Posted 7 years ago on Tuesday January 15, 2013 | Permalink
  11. @Chris Hajer - i opened up a priority support ticket for you to examine my site and theme in detail. Thanks we should talk there and then I'll post the results.

    Posted 7 years ago on Thursday January 17, 2013 | Permalink
  12. I have your priority support ticket now. I don't normally handle those, so it took a couple days to get over to me. I'll have a look at it in the next 24 hours. Thank you.

    Posted 7 years ago on Tuesday January 22, 2013 | Permalink
  13. I feel like we resolved this via email. Can you please update the topic if so with the resolution? Thank you.

    Posted 7 years ago on Friday January 25, 2013 | Permalink
  14. Matthew, I sent you an email today.

    Posted 7 years ago on Tuesday February 5, 2013 | Permalink
  15. Great help Chris. Here is the solution if anyone wants to prepopulate a list type field with a dropdown that contains custom post type items:

    http://pastie.org/6075607

    Posted 7 years ago on Tuesday February 5, 2013 | Permalink
  16. Hello. I just purchased Gravity Forms and am trying to accomplish exactly this!

    I tried adding the PHP from the pastie above to my functions.php file. I changed the post type to the one I want to populate the dropdown. The dropdown appears now, but it's empty, unpopulated.

    This is what it looks like: http://pastie.org/7153628

    What I was wondering: is the PHP above the extent of what I need to add to my functions.php file?... or are there other additions that need to be made?

    Posted 7 years ago on Thursday March 28, 2013 | Permalink
  17. There are no other code additions to be made. You will have to debug this. On line 7, I would add this statement for debugging:

    [php]
    print_r($post);

    And see what that displays. We need to start there to see if the $posts array is being filled with the correct data.

    Posted 7 years ago on Sunday March 31, 2013 | Permalink
  18. Thanks for the response. It turns out, the options are being listed, but in the wrong place. Instead of appearing in the dropdown, they appear in a list below/after the form. Any idea why this is happening?

    Posted 6 years ago on Tuesday April 16, 2013 | Permalink
  19. Just thought I'd ask once again. I have no idea why this is happening. I'm using this (http://pastie.org/7153628) in my functions.php file. The dropdown menu shows the correct label "Select Employee Name", but none of the options are listed. Instead, they appear in a list below the form. What am I doing wrong? This must be something very simple.

    Posted 6 years ago on Tuesday April 23, 2013 | Permalink

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