<?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: Pre-Render and Single Line Text / Name</title>
		<link>https://legacy.forums.gravityhelp.com/topic/pre-render-and-single-line-text-name</link>
		<description>Gravity Support Forums Topic: Pre-Render and Single Line Text / Name</description>
		<language>en-US</language>
		<pubDate>Mon, 20 Apr 2026 01:13:02 +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/pre-render-and-single-line-text-name" rel="self" type="application/rss+xml" />

		<item>
			<title>Chris Hajer on "Pre-Render and Single Line Text / Name"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/pre-render-and-single-line-text-name#post-109182</link>
			<pubDate>Thu, 27 Dec 2012 15:53:39 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">109182@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Thank you for posting your solution.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>SomethingSeven on "Pre-Render and Single Line Text / Name"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/pre-render-and-single-line-text-name#post-109104</link>
			<pubDate>Thu, 27 Dec 2012 11:59:08 +0000</pubDate>
			<dc:creator>SomethingSeven</dc:creator>
			<guid isPermaLink="false">109104@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi Chris,&#60;/p&#62;
&#60;p&#62;I wound starting over with this and now it works like a top.  I'll include the code so other people can use the the solution I worked out last night.  &#60;/p&#62;
&#60;p&#62;As a summary, I'm using the gform_field_value_$parameter_name filter as you suggested.  The documentation is here:&#60;br /&#62;
&#60;a href=&#34;http://www.gravityhelp.com/documentation/page/Gform_field_value_$parameter_name&#34; rel=&#34;nofollow&#34;&#62;http://www.gravityhelp.com/documentation/page/Gform_field_value_$parameter_name&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;I'm doing custom MySQL queries to the wp_rg_lead_detail table to get data out of a form that's been previously submitted (Form 1), then populating that data into a new form (Form 2).&#60;/p&#62;
&#60;p&#62;The following code pulls the cell phone number out of Form 1, and dynamically populated the cell phone input box in Form 2.&#60;br /&#62;
Key things to remember:&#60;br /&#62;
1) you must change the following code to reflect your form number.&#60;br /&#62;
2) you must enable the &#34;Allow field to be populated dynamically&#34; under the Admin tab on the form input you want to populate.&#60;br /&#62;
3)  you must use &#34;cellphone&#34; (with out quotes) as the dynamic population parameter.&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;&#38;lt;?php

	add_filter(&#38;quot;gform_field_value_cellphone&#38;quot;, &#38;quot;populate_cellphone&#38;quot;);
	function populate_cellphone($value) {
		global $wpdb;
		// Change this to be the number of the form you&#38;#39;re using
		$form_id = 1;
		// Do a direct MySQL lookup based on the entry_id you need
		$sql = &#38;quot;
			SELECT
				ld.lead_id,
				ld.field_number,
				ld.value
			FROM
				wp_rg_lead_detail ld
				INNER JOIN wp_rg_lead l ON ld.lead_id = l.id
			WHERE
				ld.form_id = %d AND lead_id = &#38;#39;&#38;quot;.$_REQUEST[&#38;#39;entry_id&#38;#39;].&#38;quot;&#38;#39;
			ORDER BY
				ld.lead_id,
				ld.field_number
		&#38;quot;;
		$sql = $wpdb-&#38;gt;prepare($sql,$form_id);
		$results = $wpdb-&#38;gt;get_results($sql, ARRAY_A);
		$form_answers = array();
		foreach($results as $row) {
			$row = (object)$row;
			$major_num = (int)$row-&#38;gt;field_number;
			$minor_num = (int)(($row-&#38;gt;field_number-$major_num)*10);
			$form_answers[$row-&#38;gt;lead_id][$major_num][$minor_num] = $row-&#38;gt;value;
		}
		// Iterate through the array of data pulled from the dB
		foreach($form_answers as $i =&#38;gt; $lead) {
			foreach($lead as $j =&#38;gt; $form_answer) {
				$form_answers[$i][$j] = implode(&#38;#39; &#38;#39;,$form_answer);
			}
		}
		// DUMP the variables to see what&#38;#39;s in the array
		// Uncomment the line containing print_r below to see everything
		// that&#38;#39;s pulled from the MySQL Query. This will show you the correct
		// position for the data you&#38;#39;re looking for
		//echo &#38;#39;&#38;lt;pre&#38;gt;&#38;#39;; print_r($form_answers); echo &#38;#39;&#38;lt;/pre&#38;gt;&#38;#39;;

		$my_lead_id = $_REQUEST[&#38;#39;entry_id&#38;#39;];

		// Return the requested variable - note, 14 is the position of the
		// cell phone number in the array of data pulled from the dB
		return $form_answers[$my_lead_id][&#38;#39;14&#38;#39;];
	}
?&#38;gt;&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>Chris Hajer on "Pre-Render and Single Line Text / Name"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/pre-render-and-single-line-text-name#post-108555</link>
			<pubDate>Wed, 26 Dec 2012 18:44:10 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">108555@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;What is the error which shows up?&#60;/p&#62;
&#60;p&#62;I don't think I can help any more from here.  Is this a live site or can I log in and take a look at the code you have and the data and form that you have?  If I can log in to this site, please send me at WordPress administrator login to &#60;a href=&#34;mailto:chris@rocketgenius.com&#34;&#62;chris@rocketgenius.com&#60;/a&#62; - thank you.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>SomethingSeven on "Pre-Render and Single Line Text / Name"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/pre-render-and-single-line-text-name#post-108553</link>
			<pubDate>Wed, 26 Dec 2012 18:35:53 +0000</pubDate>
			<dc:creator>SomethingSeven</dc:creator>
			<guid isPermaLink="false">108553@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Chris, &#60;/p&#62;
&#60;p&#62;I tried as you suggested, but changing it to&#60;br /&#62;
'foreach($form_data as &#38;amp;$field)'&#60;br /&#62;
 breaks the script.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Chris Hajer on "Pre-Render and Single Line Text / Name"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/pre-render-and-single-line-text-name#post-108548</link>
			<pubDate>Wed, 26 Dec 2012 18:24:50 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">108548@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;It's hard to guess without having the code, the data and the form, but I think we're getting closer.&#60;/p&#62;
&#60;p&#62;Can you change line 11 in your last example FROM this:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;foreach($form_data[&#38;quot;fields&#38;quot;] as &#38;amp;$field)&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;to this:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;foreach($form_data as &#38;amp;$field)&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;I'm not sure why &#34;fields&#34; was there.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>SomethingSeven on "Pre-Render and Single Line Text / Name"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/pre-render-and-single-line-text-name#post-108534</link>
			<pubDate>Wed, 26 Dec 2012 17:34:16 +0000</pubDate>
			<dc:creator>SomethingSeven</dc:creator>
			<guid isPermaLink="false">108534@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I think you're right Chris, but I can't seem to fix it.. I added a couple of counter variables that increment as I go through the iteration, and it appears $field[&#34;field_number&#34;] has no values..&#60;/p&#62;
&#60;p&#62;Here is the var_dump($form_data):&#60;br /&#62;
&#60;a href=&#34;http://pastebin.com/GJuGcG77&#34; rel=&#34;nofollow&#34;&#62;http://pastebin.com/GJuGcG77&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;And here is a link to the code that contains the filter to populate the singlelinetext input box on one of my forms (and the var_dump above):&#60;br /&#62;
&#60;a href=&#34;http://pastebin.com/MMguScMU&#34; rel=&#34;nofollow&#34;&#62;http://pastebin.com/MMguScMU&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;When I var_dump or print_r, I see that I have the correct record I'm looking for, but how the heck do i access the data once I have the right record??
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Chris Hajer on "Pre-Render and Single Line Text / Name"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/pre-render-and-single-line-text-name#post-108520</link>
			<pubDate>Wed, 26 Dec 2012 16:47:52 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">108520@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Also on line 13, I'm not sure you're iterating over the array correctly.  Since you are doing foreach($form_data[&#34;fields&#34;] as &#38;amp;$field), you would normally check each $field, not each $form_data['whatever'].  I would be curious to see what $form_data looks like on line 10 (with var_dump or print_r).  That might give us a clue to the correct way to get at the values.  You could also echo the value of $form_data[&#34;field_number&#34;] around line 12.5 (between line 12, and 13, outside the loop.)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>SomethingSeven on "Pre-Render and Single Line Text / Name"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/pre-render-and-single-line-text-name#post-108512</link>
			<pubDate>Wed, 26 Dec 2012 16:30:31 +0000</pubDate>
			<dc:creator>SomethingSeven</dc:creator>
			<guid isPermaLink="false">108512@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Chris,&#60;/p&#62;
&#60;p&#62;Thanks for the suggestion - 1.3 was changed to '1.3', and the checkbox for &#34;allow field to be populated dynamically&#34; is checked and the parameter name singlelinetext is used (w no quotes).. but it didn't make any difference.  Do you see anything else in the code that is wonky?&#60;/p&#62;
&#60;p&#62;Thanks!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Chris Hajer on "Pre-Render and Single Line Text / Name"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/pre-render-and-single-line-text-name#post-108506</link>
			<pubDate>Wed, 26 Dec 2012 16:19:58 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">108506@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I think on line 13 the 1.3 should be quoted, since it's a string.  Like this:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;[php]
if($form_data[&#38;quot;field_number&#38;quot;] == &#38;#39;1.3&#38;#39;)&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Also, be sure the field you want to populate is marked &#34;allow field to be populated dynamically&#34; and that this is the parameter name: 'singlelinetext' (without the quotes.)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>SomethingSeven on "Pre-Render and Single Line Text / Name"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/pre-render-and-single-line-text-name#post-108463</link>
			<pubDate>Wed, 26 Dec 2012 15:25:48 +0000</pubDate>
			<dc:creator>SomethingSeven</dc:creator>
			<guid isPermaLink="false">108463@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi Chris,&#60;/p&#62;
&#60;p&#62;Thanks for the prompt reply.&#60;/p&#62;
&#60;p&#62;I can populate a single line text input on my form with a hardcoded message - no problem.&#60;/p&#62;
&#60;p&#62;But what I need to do is a database lookup to get some form inputs out of Form 1, then populate some form fields in Form 2.&#60;/p&#62;
&#60;p&#62;Here is my code, but this isn't populating anything when I return $my_field.  Can you point out anything I'm doing wrong?&#60;/p&#62;
&#60;p&#62;Thanks a ton!&#60;/p&#62;
&#60;p&#62;Code:&#60;br /&#62;
&#60;a href=&#34;http://pastebin.com/dAyDtHFm&#34; rel=&#34;nofollow&#34;&#62;http://pastebin.com/dAyDtHFm&#60;/a&#62;
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
