<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Gravity Support Forums Topic: Dynamically populate dropdown with custom fields?</title>
		<link>https://legacy.forums.gravityhelp.com/topic/dynamically-populate-dropdown-with-custom-fields</link>
		<description>Gravity Support Forums Topic: Dynamically populate dropdown with custom fields?</description>
		<language>en-US</language>
		<pubDate>Sun, 19 Apr 2026 18:43:56 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.1</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>https://legacy.forums.gravityhelp.com/search.php</link>
		</textInput>
		<atom:link href="https://legacy.forums.gravityhelp.com/rss/topic/dynamically-populate-dropdown-with-custom-fields" rel="self" type="application/rss+xml" />

		<item>
			<title>Web Developer on "Dynamically populate dropdown with custom fields?"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/dynamically-populate-dropdown-with-custom-fields#post-55637</link>
			<pubDate>Wed, 18 Apr 2012 08:48:55 +0000</pubDate>
			<dc:creator>Web Developer</dc:creator>
			<guid isPermaLink="false">55637@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I was just trying to demonstrate that you need to pre-populate drop downs.&#60;/p&#62;
&#60;p&#62;I'm using this with MySQL calls to populate the drop downs. You could use that or a switch in the 'else' area that builds the list from, say &#34;get_the_ID()&#34;.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Shaun on "Dynamically populate dropdown with custom fields?"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/dynamically-populate-dropdown-with-custom-fields#post-55604</link>
			<pubDate>Wed, 18 Apr 2012 04:34:38 +0000</pubDate>
			<dc:creator>Shaun</dc:creator>
			<guid isPermaLink="false">55604@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Thanks for your reply, but this is no good for me.&#60;/p&#62;
&#60;p&#62;As I said above, the form appears on every produce page, but every product has different colours available. If I did your method, it would show options for all the colours on all the products. I need it to dynamically populate the drop-down with only the colours available for the product the person is looking at. These are stored in custom fields.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Web Developer on "Dynamically populate dropdown with custom fields?"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/dynamically-populate-dropdown-with-custom-fields#post-55488</link>
			<pubDate>Tue, 17 Apr 2012 11:16:48 +0000</pubDate>
			<dc:creator>Web Developer</dc:creator>
			<guid isPermaLink="false">55488@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I just started using Gravity Forms and wanted to populate a drop down with a dynamic list of employees who were working at the time the form was submitted. I was running into the same problem as you when I found what needs to be done: you have to pre-populate the form.&#60;/p&#62;
&#60;p&#62;In the following example, replace #FORM_ID# with the form's ID. Also, in the drop down, make sure you set the #CSS_CLASS# to a value in the Advanced &#38;gt; Css Class Name settings and edit the following code, replacing it to match what you put on your Gravity Form settings.&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;add_filter(&#38;#39;gform_pre_render_#FORM_ID#&#38;#39;, &#38;#39;my_populate_colors&#38;#39;);
function my_populate_colors($form) {
	foreach($form[&#38;#39;fields&#38;#39;] as &#38;amp;$field):
		if($field[&#38;#39;type&#38;#39;] != &#38;#39;select&#38;#39; &#124;&#124; strpos($field[&#38;#39;cssClass&#38;#39;], &#38;#39;#CSS_NAME#&#38;#39;) === false):
			continue;
		else:
			$choices = array();
			$choices[] = array(&#38;#39;text&#38;#39; =&#38;gt; &#38;#39;Colour name&#38;#39;, &#38;#39;value&#38;#39; =&#38;gt; &#38;#39;colour name&#38;#39;);
			$choices[] = array(&#38;#39;text&#38;#39; =&#38;gt; &#38;#39;Colour name 2&#38;#39;, &#38;#39;value&#38;#39; =&#38;gt; &#38;#39;colour name 2&#38;#39;);
			$field[&#38;#39;choices&#38;#39;] = $choices;
		endif;
	endforeach;
	return $form;
}&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>Shaun on "Dynamically populate dropdown with custom fields?"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/dynamically-populate-dropdown-with-custom-fields#post-54075</link>
			<pubDate>Tue, 03 Apr 2012 12:04:39 +0000</pubDate>
			<dc:creator>Shaun</dc:creator>
			<guid isPermaLink="false">54075@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I have an enquiry form that appears on every 'product page' which dynamically populates a text box with the product name, so far so good, but I'd like to add a dynamic drop-down to let the user pick a colour from the available colours.&#60;/p&#62;
&#60;p&#62;Colours are stored in an array in a custom field, but I can't figure out how to use this custom field to populate a drop-down. Using the same code for the text field but using an array does not seem to work. Please see my code below and let me know where I am going wrong?&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;add_filter(&#38;quot;gform_field_value_colour&#38;quot;, &#38;quot;populate_list&#38;quot;);
function populate_list($value){
     $choices[] = array(array(&#38;#39;text&#38;#39; =&#38;gt; &#38;#39;Colour name&#38;#39;, &#38;#39;value&#38;#39; =&#38;gt; &#38;#39;colour name&#38;#39;));
     $choices[] = array(array(&#38;#39;text&#38;#39; =&#38;gt; &#38;#39;Colour name 2&#38;#39;, &#38;#39;value&#38;#39; =&#38;gt; &#38;#39;colour name 2&#38;#39;));
return $choices;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Regards&#60;br /&#62;
Shaun
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
