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.

Auto Populate Drop Down using a List or an Array (gform_pre_render)

  1. After going through the gform_pre_render tutorial a gazillion times, I have successfully implemented the tutorial code in a form. However, instead of auto populating the drop down with post titles, I would like to have it populate from an array/list of "Suppliers" (ex. Acme, Delco, Volvo). What would I replace in the attached script to accomplish this?

    http://pastie.org/5658382

    TIA
    Rat

    Posted 6 years ago on Thursday January 10, 2013 | Permalink
  2. David Peralty
    Administrator

    It all depends on where you are getting this list of suppliers. Is it in a database? In a text file? Just a stock list you have? In the end, if you feed the script you have an array of values and then loop through that array, you'll be able to accomplish the same result. All my best!

    Posted 6 years ago on Thursday January 10, 2013 | Permalink
  3. Hi David! I was hoping you were around :)

    I actually don't have a preference as to where the list originates from, it could be an external text file or a built in array (there is no DB with the info). I have built an array similar to what I need in a static PHP form, but I can't for the life of me figure out how this fits together with GF. So I guess I need to ask...is one way better than another? If not, how would I go about using a text file?

    TIA
    Rat

    Posted 6 years ago on Thursday January 10, 2013 | Permalink
  4. David Peralty
    Administrator

    You could just hard code it using the following: http://www.gravityhelp.com/documentation/page/Gform_column_input

    Posted 6 years ago on Thursday January 10, 2013 | Permalink
  5. This looks really promising! Thank you!

    Rat

    Posted 6 years ago on Thursday January 10, 2013 | Permalink