<?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-rendered Checkboxes Won&#039;t Submit</title>
		<link>https://legacy.forums.gravityhelp.com/topic/pre-rendered-checkboxes-wont-submit</link>
		<description>Gravity Support Forums Topic: Pre-rendered Checkboxes Won&#039;t Submit</description>
		<language>en-US</language>
		<pubDate>Sun, 19 Apr 2026 23:30:57 +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-rendered-checkboxes-wont-submit" rel="self" type="application/rss+xml" />

		<item>
			<title>Chris Hajer on "Pre-rendered Checkboxes Won&#039;t Submit"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/pre-rendered-checkboxes-wont-submit#post-75972</link>
			<pubDate>Tue, 18 Sep 2012 02:48:53 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">75972@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Thank you for posting that as well.  I'm certain that will be helpful to someone.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Anonymous on "Pre-rendered Checkboxes Won&#039;t Submit"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/pre-rendered-checkboxes-wont-submit#post-75830</link>
			<pubDate>Mon, 17 Sep 2012 08:38:13 +0000</pubDate>
			<dc:creator>Anonymous</dc:creator>
			<guid isPermaLink="false">75830@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi Chris,&#60;/p&#62;
&#60;p&#62;I have found out that checkbox items added dynamically on &#34;gform_pre_render&#34; / &#34;gform_admin_pre_render&#34; are not available to functions added to form submission hooks (such as &#34;gform_validation&#34;, &#34;gform_pre_submission&#34; etc), unless the form is saved in the GF admin area after dynamic population.&#60;/p&#62;
&#60;p&#62;When pure arbitrary data is used to pre-render the checkboxes, the above workaround is not possible.&#60;/p&#62;
&#60;p&#62;Therefore I use the following approach which seems to work very well for me: on &#34;gform_pre_render&#34; I use RGFormsModel::get_form_meta() method to fetch the form from database, then populate the form controls as required, and then the form is saved back to the database using RGFormsModel::update_form_meta(). This behaviour can be controlled using a boolean constant, as shown below:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;// When true, the form will be saved to DB after dynamic population
define(&#38;quot;SAVE_FORM_ON_PRE_RENDER&#38;quot;, true);

// Adds a filter to form id 26. Replace 26 with your actual form id
add_filter(&#38;quot;gform_pre_render_26&#38;quot;, populate_checkbox);
add_filter(&#38;quot;gform_admin_pre_render_26&#38;quot;, populate_checkbox);

function populate_checkbox($form) {

    if (SAVE_FORM_ON_PRE_RENDER)
      $the_form = RGFormsModel::get_form_meta($form[&#38;#39;id&#38;#39;]);
    else
      $the_form = &#38;amp;$form;

    // Creating choices
    $choices = array(
      array(&#38;quot;text&#38;quot; =&#38;gt; &#38;quot;Test 1&#38;quot;, &#38;quot;value&#38;quot; =&#38;gt; &#38;quot;test1&#38;quot;),
      array(&#38;quot;text&#38;quot; =&#38;gt; &#38;quot;Test 2&#38;quot;, &#38;quot;value&#38;quot; =&#38;gt; &#38;quot;test2&#38;quot;),
      array(&#38;quot;text&#38;quot; =&#38;gt; &#38;quot;Test 3&#38;quot;, &#38;quot;value&#38;quot; =&#38;gt; &#38;quot;test3&#38;quot;),
    );

    $inputs = array(
      array(&#38;quot;label&#38;quot; =&#38;gt; &#38;quot;Test 1&#38;quot;, &#38;quot;id&#38;quot; =&#38;gt; &#38;quot;2.1&#38;quot;), //replace 2 in 2.1 with your field id
      array(&#38;quot;label&#38;quot; =&#38;gt; &#38;quot;Test 2&#38;quot;, &#38;quot;id&#38;quot; =&#38;gt; &#38;quot;2.2&#38;quot;), //replace 2 in 2.2 with your field id
      array(&#38;quot;label&#38;quot; =&#38;gt; &#38;quot;Test 2&#38;quot;, &#38;quot;id&#38;quot; =&#38;gt; &#38;quot;2.3&#38;quot;), //replace 2 in 2.3 with your field id
    );

    // Adding items to field id 2. Replace 2 with your actual field id.
    // You can get the field id by looking at the input name in the markup.
    foreach ($the_form[&#38;quot;fields&#38;quot;] as &#38;amp;$field) {
        // replace 2 with your checkbox field id
        if ($field[&#38;quot;id&#38;quot;] == 2) {
            $field[&#38;quot;choices&#38;quot;] = $choices;
            $field[&#38;quot;inputs&#38;quot;] = $inputs;
        }
    }

    // Save form to database, if constant is set to true
    if (SAVE_FORM_ON_PRE_RENDER)
      RGFormsModel::update_form_meta($form[&#38;#39;id&#38;#39;], $the_form);

  return $the_form;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Using this approach you can view the checkbox values in the entry list as well as change the entry, by updating the submitted checkbox values.&#60;/p&#62;
&#60;p&#62;Hope this helps.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Chris Hajer on "Pre-rendered Checkboxes Won&#039;t Submit"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/pre-rendered-checkboxes-wont-submit#post-75405</link>
			<pubDate>Fri, 14 Sep 2012 17:12:53 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">75405@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Thank you for finding that mobt.  I tried yesterday and could not remember the phrase &#34;surprisingly complex.&#34;  It's good to re-read that one.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Anonymous on "Pre-rendered Checkboxes Won&#039;t Submit"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/pre-rendered-checkboxes-wont-submit#post-75402</link>
			<pubDate>Fri, 14 Sep 2012 16:54:44 +0000</pubDate>
			<dc:creator>Anonymous</dc:creator>
			<guid isPermaLink="false">75402@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;This happens because checkboxes are treated as multi-input fields. Please see this thread:&#60;br /&#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;</description>
		</item>
		<item>
			<title>Chris Hajer on "Pre-rendered Checkboxes Won&#039;t Submit"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/pre-rendered-checkboxes-wont-submit#post-75269</link>
			<pubDate>Fri, 14 Sep 2012 01:06:55 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">75269@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;For the field &#34;Select the Dog(s) You are Interested in Adopting:*&#34; I submitted without checking a box, and got a validation error.  When I submitted with the last box checked, I passed that page and was at a confirmation page.  I did not have to check the first dog as the one I wanted to adopt.  Is that the same as your experience?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>ncmccance on "Pre-rendered Checkboxes Won&#039;t Submit"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/pre-rendered-checkboxes-wont-submit#post-74971</link>
			<pubDate>Wed, 12 Sep 2012 12:34:00 +0000</pubDate>
			<dc:creator>ncmccance</dc:creator>
			<guid isPermaLink="false">74971@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I'm having a problem with a field of pre-rendered checkboxes that will only submit if the first checkbox is selected. Users should be able to select any of the checkboxes and submit the form, but they are unable to submit said form unless that first checkbox is checked.&#60;/p&#62;
&#60;p&#62;Here is the URL for the form itself: &#60;a href=&#34;http://midwestrescue.org/adoption-application/&#34; rel=&#34;nofollow&#34;&#62;http://midwestrescue.org/adoption-application/&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;Here is the code I've used to pre-render the field:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;add_filter(&#38;#39;gform_pre_render_2&#38;#39;, &#38;#39;mwr_populate_dogs&#38;#39;);
add_filter(&#38;#39;gform_admin_pre_render_2&#38;#39;, &#38;#39;mwr_populate_dogs&#38;#39;);
function mwr_populate_dogs($form){

	$posts = get_posts(&#38;#39;cat=4&#38;amp;numberposts=-1&#38;amp;post_status=publish&#38;amp;meta_value=internal&#38;#39;);

	$adoptabulls = array();

	foreach($posts as $post){
		$adoptabulls[] = array(&#38;#39;text&#38;#39; =&#38;gt; $post-&#38;gt;post_title, &#38;#39;value&#38;#39; =&#38;gt; $post-&#38;gt;post_title);
	}

	$adoptabulls[] = array(&#38;#39;text&#38;#39; =&#38;gt; &#38;#39;Adoptabull Not Listed&#38;#39;, &#38;#39;value&#38;#39; =&#38;gt; &#38;#39;Adoptabull Not Listed&#38;#39;);

	foreach($form[&#38;#39;fields&#38;#39;] as &#38;amp;$field){
		if($field[&#38;#39;id&#38;#39;] == 58) {
			$field[&#38;#39;choices&#38;#39;] = $adoptabulls;
		}
	}

	return $form;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Am I missing something?
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
