<?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: What&#039;s the best way to pre-populate multiple fields on a single form?</title>
		<link>https://legacy.forums.gravityhelp.com/topic/whats-the-best-way-to-pre-populate-multiple-fields-on-a-single-form</link>
		<description>Gravity Support Forums Topic: What&#039;s the best way to pre-populate multiple fields on a single form?</description>
		<language>en-US</language>
		<pubDate>Sat, 18 Apr 2026 01:47:07 +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/whats-the-best-way-to-pre-populate-multiple-fields-on-a-single-form" rel="self" type="application/rss+xml" />

		<item>
			<title>Carl Hancock on "What&#039;s the best way to pre-populate multiple fields on a single form?"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/whats-the-best-way-to-pre-populate-multiple-fields-on-a-single-form#post-20603</link>
			<pubDate>Tue, 15 Mar 2011 11:24:07 +0000</pubDate>
			<dc:creator>Carl Hancock</dc:creator>
			<guid isPermaLink="false">20603@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;That is correct.  Your code would only change the form display when it is shown to the user.  If you edit the entry in the admin, it's going to show the checkboxes values associated with the form configuration itself and not your custom code.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Shauna on "What&#039;s the best way to pre-populate multiple fields on a single form?"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/whats-the-best-way-to-pre-populate-multiple-fields-on-a-single-form#post-20574</link>
			<pubDate>Mon, 14 Mar 2011 22:48:31 +0000</pubDate>
			<dc:creator>Shauna</dc:creator>
			<guid isPermaLink="false">20574@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;@Carl, thanks for the quick reply.  If I read the comment correctly, it is possible to display a drop down list dynamically, but it isn't possible to &#34;update&#34;, ie, indicate which elements are checked. Is that right?&#60;/p&#62;
&#60;p&#62;&#34;....... It will allow the checkboxes to be added to your form and you will be able to view the entry in the admin detail screen, but you won't be able to change the entry and update the checkbox values.&#34;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Carl Hancock on "What&#039;s the best way to pre-populate multiple fields on a single form?"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/whats-the-best-way-to-pre-populate-multiple-fields-on-a-single-form#post-20564</link>
			<pubDate>Mon, 14 Mar 2011 17:26:52 +0000</pubDate>
			<dc:creator>Carl Hancock</dc:creator>
			<guid isPermaLink="false">20564@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;@Shauna See this forum thread on populating checkboxes:&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://www.gravityhelp.com/forums/topic/dynamic-checkboxes&#34; rel=&#34;nofollow&#34;&#62;http://www.gravityhelp.com/forums/topic/dynamic-checkboxes&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;Checkboxes are actually one of the most complex fields to interact with because unlike Drop Downs and Radio Buttons which consist of multiple values, they are really only one input.  Checkboxes on the other hand are multiple inputs.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Shauna on "What&#039;s the best way to pre-populate multiple fields on a single form?"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/whats-the-best-way-to-pre-populate-multiple-fields-on-a-single-form#post-20563</link>
			<pubDate>Mon, 14 Mar 2011 17:24:51 +0000</pubDate>
			<dc:creator>Shauna</dc:creator>
			<guid isPermaLink="false">20563@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I am having a tough time figuring out how to set the default value of grouped fields or checkboxes.  Can you point me in the right direction. &#60;/p&#62;
&#60;p&#62;I have figured out with grouped fields you can basically assign each a variable name  and use the add_filter method to populate but this doesn't seem to work with multi select checkboxes as there is a single variable you can use and you can only check one option. &#60;/p&#62;
&#60;p&#62;Neither of the following are working for me with multi select checkboxes&#60;/p&#62;
&#60;p&#62;-&#38;gt; $VarMultiSelect = $data-&#38;gt;value;  //parameter name for dynamically pop variable&#60;/p&#62;
&#60;p&#62;-&#38;gt; $form[&#34;fields&#34;][40][0][&#34;checked&#34;]=true;&#60;/p&#62;
&#60;p&#62;I know the last is just a stab in the dark but there really isn't any documentation so am basically forced to try various things.&#60;/p&#62;
&#60;p&#62;Thanks for you help
&#60;/p&#62;</description>
		</item>
		<item>
			<title>anointed on "What&#039;s the best way to pre-populate multiple fields on a single form?"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/whats-the-best-way-to-pre-populate-multiple-fields-on-a-single-form#post-9109</link>
			<pubDate>Sun, 29 Aug 2010 04:44:39 +0000</pubDate>
			<dc:creator>anointed</dc:creator>
			<guid isPermaLink="false">9109@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Wow nice one!&#60;br /&#62;
@DomainWorld it goes in your theme's functions.php file
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Joe T on "What&#039;s the best way to pre-populate multiple fields on a single form?"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/whats-the-best-way-to-pre-populate-multiple-fields-on-a-single-form#post-9106</link>
			<pubDate>Sun, 29 Aug 2010 01:53:21 +0000</pubDate>
			<dc:creator>Joe T</dc:creator>
			<guid isPermaLink="false">9106@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Forgive my ignorance - where would the above code be placed?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Jeff Schodde on "What&#039;s the best way to pre-populate multiple fields on a single form?"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/whats-the-best-way-to-pre-populate-multiple-fields-on-a-single-form#post-7823</link>
			<pubDate>Mon, 26 Jul 2010 14:51:57 +0000</pubDate>
			<dc:creator>Jeff Schodde</dc:creator>
			<guid isPermaLink="false">7823@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;This makes total sense thanks!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Alex Cancado on "What&#039;s the best way to pre-populate multiple fields on a single form?"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/whats-the-best-way-to-pre-populate-multiple-fields-on-a-single-form#post-7822</link>
			<pubDate>Mon, 26 Jul 2010 14:45:35 +0000</pubDate>
			<dc:creator>Alex Cancado</dc:creator>
			<guid isPermaLink="false">7822@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Jeff,&#60;br /&#62;
Try the following:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;//replace 9 with your form Id
add_filter(&#38;quot;gform_pre_render_9&#38;quot;, &#38;quot;populate_fields&#38;quot;);
function populate_fields($form){

    global $current_user;
    get_currentuserinfo();

    foreach($form[&#38;quot;fields&#38;quot;] as &#38;amp;$field)
        switch($field[&#38;quot;id&#38;quot;])
        {
            //replace 1 with your first name field id
            case &#38;quot;1&#38;quot;:
                $field[&#38;quot;defaultValue&#38;quot;] = $current_user-&#38;gt;first_name;
            break;

            //replace 2 with your last name field id
            case &#38;quot;2&#38;quot;:
                $field[&#38;quot;defaultValue&#38;quot;] = $current_user-&#38;gt;last_name;
            break;
        }

    return $form;
}&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>Jeff Schodde on "What&#039;s the best way to pre-populate multiple fields on a single form?"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/whats-the-best-way-to-pre-populate-multiple-fields-on-a-single-form#post-7815</link>
			<pubDate>Mon, 26 Jul 2010 13:01:26 +0000</pubDate>
			<dc:creator>Jeff Schodde</dc:creator>
			<guid isPermaLink="false">7815@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Anyone?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Jeff Schodde on "What&#039;s the best way to pre-populate multiple fields on a single form?"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/whats-the-best-way-to-pre-populate-multiple-fields-on-a-single-form#post-7759</link>
			<pubDate>Sun, 25 Jul 2010 15:20:08 +0000</pubDate>
			<dc:creator>Jeff Schodde</dc:creator>
			<guid isPermaLink="false">7759@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I have one of those &#34;tell-a-friend&#34; kind of forms and I want to default the sender's name and email address with the information stored in their Wordpress profile. I got it working, but it seems like a lot of extra coding when I use one filter/function per field like this:&#60;/p&#62;
&#60;p&#62;Here's how I pre-populate the sender's name:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;add_filter(&#38;quot;gform_field_value_f2_fname&#38;quot;, &#38;quot;f2_fname&#38;quot;);
function f2_fname() {

	global $current_user;
	get_currentuserinfo();
	return $current_user-&#38;gt;user_firstname;
}

add_filter(&#38;quot;gform_field_value_f2_lname&#38;quot;, &#38;quot;f2_lname&#38;quot;);
function f2_lname() {

	global $current_user;
	get_currentuserinfo();
	return $current_user-&#38;gt;user_lastname;

}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;When you have multiple forms with the same field parameter names (i.e. fname and lname), I would think that the system would get confused because it wouldn't know which form you are referencing. &#60;/p&#62;
&#60;p&#62;My workaround for this was to pre-pend each parameter name in the form with &#34;f1&#34; for form #1 or &#34;f2&#34; for form #2. Thus, &#34;f2_fname&#34; refers to the &#34;f2_fname&#34; parameter in form #2.&#60;/p&#62;
&#60;p&#62;How can I code the function so that each one lumps all the fields into one function? Perhaps like this:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;add_filter(&#38;quot;gform_????&#38;quot;, &#38;quot;default_the_fields_on_form_2&#38;quot;);
function default_the_fields_on_form_2($form) {

	global $current_user;
	get_currentuserinfo();
	$fname=$current_user-&#38;gt;user_firstname;
        $lname=$current_user-&#38;gt;user_lastname;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Thanks,&#60;br /&#62;
Jeff
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
