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 pre-populating a drop down

  1. VFHwebdev
    Member

    I'm trying to follow this example from the documentation about how to pre-populate a drop down menu (http://www.gravityhelp.com/documentation/page/Dynamically_Populating_Drop_Down_Fields).

    It's not working and I can't figure out why. I've added the code example to my functions.php file and I've updated the code with the id of my form as instructed.

    It doesn't mention it directly in the documentation, but I assume I'm also supposed to add the class 'populate-posts' to the drop down item I want to pre-populate.

    I've done all this and it isn't working. Eventually I want to tweak the example a little, but first I'm just trying to reproduce it.

    Am I missing a step here?

    Posted 11 years ago on Tuesday March 19, 2013 | Permalink
  2. VFHwebdev
    Member

    I think I figured out what I was doing wrong. I was using a gravity form field that's a 'Post Custom Field' set to a field type of 'Drop Down'.

    This is apparently does function the same as a regular drop down and isn't caught by the conditional in the code sample:

    if($field['type'] != 'select' || strpos($field['cssClass'], 'populate-posts') === false)

    So is there documentation somewhere of the possible values for $field['type'] ?

    Posted 11 years ago on Tuesday March 19, 2013 | Permalink
  3. Is this topic related to your other one?
    http://www.gravityhelp.com/forums/topic/drop-down-of-custom-posts-stored-as-custom-field

    Can we focus the support on one topic or the other, or are the issues unrelated?

    Posted 11 years ago on Thursday March 21, 2013 | Permalink
  4. VFHwebdev
    Member

    Sorry, same project but different issues.

    In this case a custom field type with a class populate-posts, set to behave as a drop down isn't recognized by the conditional:

    if($field['type'] != 'select' || strpos($field['cssClass'], 'populate-posts') === false)

    I'm guessing the problem is the field type. I was able to make it work by removing that part.

    if(strpos($field['cssClass'], 'populate-posts') === false)

    This is OK for me because there's only one field with a populate-posts class in my form. But it seems like custom field types set to be select boxes should behave like select boxes.

    And I can't find any documentation on the possible vaules for field type. Is a custom field a type of 'custom'?

    Thanks.

    Posted 11 years ago on Thursday March 21, 2013 | Permalink
  5. I don't know of any documentation for those fields types. I did look through the source and found all these types though:

    • select
    • radio
    • text
    • calculation
    • textbox
    • website
    • phone
    • email
    • list
    • singleproduct

    However, I'm not sure if that will help you. Can you post all the code you are using to populate the drop down and we'll take a look at it and see if we can spot a problem.

    Posted 11 years ago on Sunday March 24, 2013 | Permalink