<?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: drop down value different than content text</title>
		<link>https://legacy.forums.gravityhelp.com/topic/drop-down-value-different-than-content-text</link>
		<description>Gravity Support Forums Topic: drop down value different than content text</description>
		<language>en-US</language>
		<pubDate>Mon, 20 Apr 2026 10:07:09 +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/drop-down-value-different-than-content-text" rel="self" type="application/rss+xml" />

		<item>
			<title>ramon fincken on "drop down value different than content text"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/drop-down-value-different-than-content-text#post-15676</link>
			<pubDate>Sat, 08 Jan 2011 09:42:21 +0000</pubDate>
			<dc:creator>ramon fincken</dc:creator>
			<guid isPermaLink="false">15676@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Thanks Jan, works like a charm!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Nick Ciske on "drop down value different than content text"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/drop-down-value-different-than-content-text#post-8477</link>
			<pubDate>Thu, 12 Aug 2010 11:04:48 +0000</pubDate>
			<dc:creator>Nick Ciske</dc:creator>
			<guid isPermaLink="false">8477@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;FYI- if you want to set isSelected this way, you have to turn off the &#34;Allow field to be populated dynamically&#34; option to avoid GF overriding the manually set selection -- at least that's what I had to do to get my form working.&#60;/p&#62;
&#60;p&#62;This came in very handy when I needed to populate a drop down with a list of custom post types!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Erwin van den Boogaard on "drop down value different than content text"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/drop-down-value-different-than-content-text#post-3336</link>
			<pubDate>Fri, 12 Feb 2010 08:12:02 +0000</pubDate>
			<dc:creator>Erwin van den Boogaard</dc:creator>
			<guid isPermaLink="false">3336@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Alex wrote you don't need the second loop to set the &#34;isSelected&#34; property, but you seem to do the same as I did two posts ago ;)&#60;br /&#62;
What's this different than the code that I came up with?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Jan Egbert on "drop down value different than content text"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/drop-down-value-different-than-content-text#post-3335</link>
			<pubDate>Fri, 12 Feb 2010 06:57:40 +0000</pubDate>
			<dc:creator>Jan Egbert</dc:creator>
			<guid isPermaLink="false">3335@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Try the snippet below. Not sure if it's the most effecient method. But it seems to work fine.&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;add_filter(&#38;quot;gform_pre_render_4&#38;quot;, &#38;quot;populate_and_preselect_country&#38;quot;);
function populate_and_preselect_country($form){

    $mycountries = array();

	$mycountries[] = array(&#38;quot;name&#38;quot; =&#38;gt; &#38;quot;Canada&#38;quot;, &#38;quot;value&#38;quot; =&#38;gt; &#38;quot;CA&#38;quot;);
    $mycountries[] = array(&#38;quot;name&#38;quot; =&#38;gt; &#38;quot;France&#38;quot;, &#38;quot;value&#38;quot; =&#38;gt; &#38;quot;FR&#38;quot;);
    $mycountries[] = array(&#38;quot;name&#38;quot; =&#38;gt; &#38;quot;Germany&#38;quot;, &#38;quot;value&#38;quot; =&#38;gt; &#38;quot;DE&#38;quot;);
    $mycountries[] = array(&#38;quot;name&#38;quot; =&#38;gt; &#38;quot;Netherlands&#38;quot;, &#38;quot;value&#38;quot; =&#38;gt; &#38;quot;NL&#38;quot;);
    $mycountries[] = array(&#38;quot;name&#38;quot; =&#38;gt; &#38;quot;United Kingdom&#38;quot;, &#38;quot;value&#38;quot; =&#38;gt; &#38;quot;GB&#38;quot;);
    $mycountries[] = array(&#38;quot;name&#38;quot; =&#38;gt; &#38;quot;United States&#38;quot;, &#38;quot;value&#38;quot; =&#38;gt; &#38;quot;US&#38;quot;);

    $items = array();

    foreach($mycountries as $mycountry){
    	$country = $_GET[&#38;quot;country&#38;quot;];
        $is_selected = $mycountry[&#38;quot;value&#38;quot;] == $country ? true : false;
        $items[] = array(&#38;quot;value&#38;quot; =&#38;gt; $mycountry[&#38;quot;value&#38;quot;], &#38;quot;text&#38;quot; =&#38;gt; $mycountry[&#38;quot;name&#38;quot;], &#38;quot;isSelected&#38;quot;=&#38;gt; $is_selected);
    }

    foreach($form[&#38;quot;fields&#38;quot;] as &#38;amp;$field)
        if($field[&#38;quot;id&#38;quot;] == 1){
            $field[&#38;quot;type&#38;quot;] = &#38;quot;select&#38;quot;;
            $field[&#38;quot;choices&#38;quot;] = $items;
        }

    return $form;
}&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>Erwin van den Boogaard on "drop down value different than content text"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/drop-down-value-different-than-content-text#post-3334</link>
			<pubDate>Fri, 12 Feb 2010 03:52:19 +0000</pubDate>
			<dc:creator>Erwin van den Boogaard</dc:creator>
			<guid isPermaLink="false">3334@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi Alex,&#60;/p&#62;
&#60;p&#62;How do you mean 'technically you don't need the second loop to set the &#34;isSelected&#34; property. You can just set it along with the &#34;text&#34; and &#34;value&#34; when building the $items[] array'?&#60;br /&#62;
Wouldn't i need to check the country_id if it matches? Or do you mean that i could include the 'if' while filling the array, like this:&#60;br /&#62;
&#60;code&#62;$items[] = array(&#38;quot;text&#38;quot; =&#38;gt; &#38;quot;Canada&#38;quot;, &#38;quot;value&#38;quot; =&#38;gt; &#38;quot;CA&#38;quot;, if ($country[&#38;quot;value&#38;quot;] == &#38;#39;US&#38;#39;) &#38;quot;isSelected&#38;quot;=&#38;gt; true);&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;Regarding the storage of the country in the database: it would be great if both the text and value of drop down could be accessed independently, like: {country(text):6}, {country(value):6} (just thinking out loud here ;) )&#60;/p&#62;
&#60;p&#62;Thanks,&#60;br /&#62;
Erwin
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Alex Cancado on "drop down value different than content text"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/drop-down-value-different-than-content-text#post-3326</link>
			<pubDate>Thu, 11 Feb 2010 20:50:10 +0000</pubDate>
			<dc:creator>Alex Cancado</dc:creator>
			<guid isPermaLink="false">3326@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Erwin,&#60;br /&#62;
Your code looks good (technically you don't need the second loop to set the &#34;isSelected&#34; property. You can just set it along with the &#34;text&#34; and &#34;value&#34; when building the $items[] array, but it shouldn't cause any problems as is. Good job hacking Gravity Forms! Using the &#34;value&#34; property of drop down items is something we are planning on incorporating into Gravity Forms, but haven't fully implemented it yet.&#60;/p&#62;
&#60;p&#62;The only possible drawback I can think of is that the country stored in the database will be the abbreviation. So if you send notification to users, the abbreviation will be sent. This may or may not be ok.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Erwin van den Boogaard on "drop down value different than content text"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/drop-down-value-different-than-content-text#post-3319</link>
			<pubDate>Thu, 11 Feb 2010 19:30:15 +0000</pubDate>
			<dc:creator>Erwin van den Boogaard</dc:creator>
			<guid isPermaLink="false">3319@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Sorry to say, but it didn't work :(&#60;/p&#62;
&#60;p&#62;I have this to populate the drop down (this works)&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;add_filter( &#38;#39;gform_pre_render_1&#38;#39;, &#38;#39;populate_dropdown&#38;#39; );
function populate_dropdown($form){
    $items = array();
    $items[] = array(&#38;quot;text&#38;quot; =&#38;gt; &#38;quot;Canada&#38;quot;, &#38;quot;value&#38;quot; =&#38;gt; &#38;quot;CA&#38;quot;);
    $items[] = array(&#38;quot;text&#38;quot; =&#38;gt; &#38;quot;France&#38;quot;, &#38;quot;value&#38;quot; =&#38;gt; &#38;quot;FR&#38;quot;);
    $items[] = array(&#38;quot;text&#38;quot; =&#38;gt; &#38;quot;Germany&#38;quot;, &#38;quot;value&#38;quot; =&#38;gt; &#38;quot;DE&#38;quot;);
    $items[] = array(&#38;quot;text&#38;quot; =&#38;gt; &#38;quot;Netherlands&#38;quot;, &#38;quot;value&#38;quot; =&#38;gt; &#38;quot;NL&#38;quot;);
    $items[] = array(&#38;quot;text&#38;quot; =&#38;gt; &#38;quot;United Kingdom&#38;quot;, &#38;quot;value&#38;quot; =&#38;gt; &#38;quot;GB&#38;quot;);
    $items[] = array(&#38;quot;text&#38;quot; =&#38;gt; &#38;quot;United States&#38;quot;, &#38;quot;value&#38;quot; =&#38;gt; &#38;quot;US&#38;quot;);

    foreach($form[&#38;quot;fields&#38;quot;] as &#38;amp;$field)
        if($field[&#38;quot;id&#38;quot;] == 6){
            $field[&#38;quot;type&#38;quot;] = &#38;quot;select&#38;quot;;
            $field[&#38;quot;choices&#38;quot;] = $items;
        }
    return $form;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Now, to pre-select the drop down the following code SHOULD work, but it doesn't:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;add_filter(&#38;quot;gform_field_value_country&#38;quot;, &#38;quot;populate_country&#38;quot;);
function populate_country(){
$country_value = &#38;#39;US&#38;#39;; // for testing purposes I hard-coded setting the value
return $country_value;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;But what SHOULD NOT work, but did work is the following:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;add_filter(&#38;quot;gform_field_value_country&#38;quot;, &#38;quot;populate_country&#38;quot;);
function populate_country(){
$country_value = &#38;#39;United States&#38;#39;;  // for testing purposes I hard-coded setting the value
return $country_value;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Unfortunately I only have the real value (US, UK, NL, etc.) to select the correct one. &#60;/p&#62;
&#60;p&#62;So here's what did work: I added the following after&#60;br /&#62;
$items[] = array(&#34;text&#34; =&#38;gt; &#34;United States&#34;, &#34;value&#34; =&#38;gt; &#34;US&#34;);&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;foreach($items as &#38;amp;$country )
		if ($country[&#38;quot;value&#38;quot;] == &#38;#39;US&#38;#39; {
			$country = array(&#38;quot;text&#38;quot; =&#38;gt; $country[&#38;quot;text&#38;quot;], &#38;quot;value&#38;quot; =&#38;gt; $country[&#38;quot;value&#38;quot;], &#38;quot;isSelected&#38;quot;=&#38;gt; true);
		}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Note: I'm not a PHP coder, I'm a code thief ;) so some copy-pasting and adding some common sense/logic takes me a long way. I did get the result I wanted BUT what I don't know is if the code will bring a heavy strain on the server or wreck my Gravity form in any way.&#60;/p&#62;
&#60;p&#62;So can you please check if my code gets your OK?&#60;/p&#62;
&#60;p&#62;Thanks,&#60;br /&#62;
Erwin
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Alex Cancado on "drop down value different than content text"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/drop-down-value-different-than-content-text#post-3308</link>
			<pubDate>Thu, 11 Feb 2010 16:56:40 +0000</pubDate>
			<dc:creator>Alex Cancado</dc:creator>
			<guid isPermaLink="false">3308@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Just to confirm, Carl's solution above will work.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Carl Hancock on "drop down value different than content text"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/drop-down-value-different-than-content-text#post-3302</link>
			<pubDate>Thu, 11 Feb 2010 14:41:27 +0000</pubDate>
			<dc:creator>Carl Hancock</dc:creator>
			<guid isPermaLink="false">3302@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Typically you would use PHP in your themes function.php to pre-select it...&#60;/p&#62;
&#60;p&#62;- Edit the field&#60;br /&#62;
- Select Advanced Tab&#60;br /&#62;
- Check the &#34;Allow field to be populated dynamically&#34; checkbox&#60;br /&#62;
- Give the field a parameter name&#60;/p&#62;
&#60;p&#62;Place the code in your function file...&#60;/p&#62;
&#60;p&#62;Ex.&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;add_filter(&#38;quot;gform_field_value_city&#38;quot;, &#38;quot;populate_city&#38;quot;);
function populate_city(){
$city_value = &#38;quot;New York&#38;quot;;
return $city_value;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;However i'm not 100% sure if it will work when you are pre-populating the actual values using custom code.&#60;/p&#62;
&#60;p&#62;BUT you can certainly try doing it this way and place the filter above to pre-select the drop down item BELOW the code where you populate the drop down... that might work.  Let me know how it goes.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Erwin van den Boogaard on "drop down value different than content text"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/drop-down-value-different-than-content-text#post-3297</link>
			<pubDate>Thu, 11 Feb 2010 12:57:56 +0000</pubDate>
			<dc:creator>Erwin van den Boogaard</dc:creator>
			<guid isPermaLink="false">3297@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;By using PHP.
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
