<?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: Dynamic population of fields by 2 variables: current date and quantity field.</title>
		<link>https://legacy.forums.gravityhelp.com/topic/dynamic-population-of-fields-by-2-variables-current-date-and-quantity-field</link>
		<description>Gravity Support Forums Topic: Dynamic population of fields by 2 variables: current date and quantity field.</description>
		<language>en-US</language>
		<pubDate>Tue, 21 Apr 2026 20:33: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/dynamic-population-of-fields-by-2-variables-current-date-and-quantity-field" rel="self" type="application/rss+xml" />

		<item>
			<title>Shelly on "Dynamic population of fields by 2 variables: current date and quantity field."</title>
			<link>https://legacy.forums.gravityhelp.com/topic/dynamic-population-of-fields-by-2-variables-current-date-and-quantity-field#post-74258</link>
			<pubDate>Thu, 06 Sep 2012 17:06:37 +0000</pubDate>
			<dc:creator>Shelly</dc:creator>
			<guid isPermaLink="false">74258@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Okay, I wanted to come back and update this, in case it would help anyone else.  I edited the form to basically show/hide (and require) a field based on the date range.  I'm gonna pop in a lot of code here, but hopefully it helps someone in the future.  it uses the stuff I mentioned in the above post.&#60;/p&#62;
&#60;p&#62;So you create one single form.  let's say, for example, that you have a membership fee that changes based on the date.  i.e. at the beginning of the year, it's full price, but when the year is half gone (say, in July) the price is reduced by 50% because the year's half over.&#60;/p&#62;
&#60;p&#62;SO what I did was create a single form, and in it (for brevity's sake, we'll do one field, but there were several in my form) there's a &#34;membership fee&#34;. Dropdown or quantity field, it doesn't matter.  You just set it as &#34;required&#34;, and set the CSS Class as &#34;fullyear&#34;.&#60;/p&#62;
&#60;p&#62;Duplicate the field.  Change the price.  Set the cssClass as &#34;midyear&#34;.&#60;/p&#62;
&#60;p&#62;Now, just add this function to your functions.php file:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;// function to convert date to UNIX timestamp
function date_comparison_fun($date=&#38;#39;&#38;#39;) {
    if(!$date) $date = date(&#38;#39;j F Y&#38;#39;); 			// default - today&#38;#39;s date
	  $date = strtotime($date); 			// UNIX conversions
    return $date;
}

//Now use the above to change the form fields based on date
add_filter(&#38;#39;gform_pre_render&#38;#39;, &#38;#39;change_form_stuff&#38;#39;, 10, 2);
function change_form_stuff($form) {
  // dates MUST be entered in day Month Year format. Example: 20 September 2012
  // blank date is today&#38;#39;s date.
  $today = date_comparison_fun();
  $year  = date(&#38;#39;Y&#38;#39;);                       // current year
  $start = date_comparison_fun(&#38;#39;30 June &#38;#39; . $year);
  $end   = date_comparison_fun(&#38;#39;31 December &#38;#39; . $year); 

  if($form[&#38;#39;id&#38;#39;] == 1) {                      // form ID you want to use this in
    //start by changing the form title
    if( ($today &#38;gt; $start) &#38;amp;&#38;amp; ($today &#38;lt; $end) )
      //if today is between start and end dates, it&#38;#39;s Mid-Year stuff
      $form[&#38;#39;title&#38;#39;] = $form[&#38;#39;title&#38;#39;] . &#38;#39; - Mid-Year Membership&#38;#39;;

      //now get to the meat - the fields
      foreach($form[&#38;#39;fields&#38;#39;] as &#38;amp;$field) {
        if( ($today &#38;gt; $start) &#38;amp;&#38;amp; ($today &#38;lt; $end) ) { // if we&#38;#39;re in between the dates
          if($field[&#38;#39;cssClass&#38;#39;] == &#38;#39;fullyear&#38;#39;) {     //full year pricing is gone
            $field[&#38;#39;isRequired&#38;#39;] = false;
            $field[&#38;#39;cssClass&#38;#39;] = $field[&#38;#39;cssClass&#38;#39;] . &#38;#39; hide&#38;#39;;
          }
        } else {                                    // else for the rest of the year
          if($field[&#38;#39;cssClass&#38;#39;] == &#38;#39;midyear&#38;#39;) {     // mid-year pricing is gone
            $field[&#38;#39;isRequired&#38;#39;] = false;
            $field[&#38;#39;cssClass&#38;#39;] = $field[&#38;#39;cssClass&#38;#39;] . &#38;#39; hide&#38;#39;;
          }
        } //end date check
      } // end foreach
    } //end checking which forms

  return $form;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;What the above does is, if it's before July 1, it'll show the &#34;full year&#34; memebership; and set the &#34;midyear&#34; field as 1) not required and 2) add an additional class of &#34;hide&#34;.  if it's after July 1, but before December 31, it'll do the opposite - fullyear is now not required and hidden, and the midyear *is* required and shown.&#60;/p&#62;
&#60;p&#62;the final step is to add this to your style.css file in your theme:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;.hide {
display:none !important;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Hope that helps someone out :)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Shelly on "Dynamic population of fields by 2 variables: current date and quantity field."</title>
			<link>https://legacy.forums.gravityhelp.com/topic/dynamic-population-of-fields-by-2-variables-current-date-and-quantity-field#post-69178</link>
			<pubDate>Thu, 02 Aug 2012 13:07:12 +0000</pubDate>
			<dc:creator>Shelly</dc:creator>
			<guid isPermaLink="false">69178@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hey JEWebDes, sorry I haven't checked back in a while.  Seems I only come around when I need something ;)  I think you *did* contact me - if it wasn't you, someone else emailed me and asked the same question, but to help others out that may have the same question, what I did in this instance was create 2 forms, and used PHP conditional logic to check the current date.  If today's date was within the &#34;reduced rate&#34; date range, it would show form #2, but if it was any other time, it would show form #1.&#60;/p&#62;
&#60;p&#62;However, since then I've discovered more goodies with the stuff you can do with Gravity Forms, and if I had to do it over again, I'm pretty sure I could make it happen with just one form.  A little while back, I had a similar question (regarding dynamic authors, instead of dates), and that forum thread is here: &#60;a href=&#34;http://www.gravityhelp.com/forums/topic/post-authors&#34; rel=&#34;nofollow&#34;&#62;http://www.gravityhelp.com/forums/topic/post-authors&#60;/a&#62;.  Knowing all of that info, I'm 100% sure I could, instead, create a single form, then write a function that would look at that one field and swap it out based on the date.  Would be MUCH easier to maintain, since you only have to mess with one form instead of two.&#60;/p&#62;
&#60;p&#62;Hope that helps someone else!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Chris Hajer on "Dynamic population of fields by 2 variables: current date and quantity field."</title>
			<link>https://legacy.forums.gravityhelp.com/topic/dynamic-population-of-fields-by-2-variables-current-date-and-quantity-field#post-66133</link>
			<pubDate>Fri, 13 Jul 2012 12:11:03 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">66133@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Her website is in her profile if you want to try to contact her:&#60;br /&#62;
&#60;a href=&#34;http://brassblogs.com&#34; rel=&#34;nofollow&#34;&#62;http://brassblogs.com&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;She might not check back in on this topic although she has been active in the past month.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>JEWebDes on "Dynamic population of fields by 2 variables: current date and quantity field."</title>
			<link>https://legacy.forums.gravityhelp.com/topic/dynamic-population-of-fields-by-2-variables-current-date-and-quantity-field#post-66129</link>
			<pubDate>Fri, 13 Jul 2012 11:35:14 +0000</pubDate>
			<dc:creator>JEWebDes</dc:creator>
			<guid isPermaLink="false">66129@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Like Shelly, I need to present one set of radio button options/prices up to a certain date, and a different set of radio button options/prices after a certain date, and I want to get my hands on the functions.php function she wrote to accomplish that because I have not figured it out mystelf.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Chris Hajer on "Dynamic population of fields by 2 variables: current date and quantity field."</title>
			<link>https://legacy.forums.gravityhelp.com/topic/dynamic-population-of-fields-by-2-variables-current-date-and-quantity-field#post-66126</link>
			<pubDate>Fri, 13 Jul 2012 11:27:49 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">66126@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;JE, can you please explain what you're looking to do?  Start a new topic if it's appropriate and we'll be happy to provide you personal assistance for your current issue.  I can't remember what Shelly came up with but she accomplished most of it on her own.&#60;/p&#62;
&#60;p&#62;Thanks,&#60;br /&#62;
Chris
&#60;/p&#62;</description>
		</item>
		<item>
			<title>JEWebDes on "Dynamic population of fields by 2 variables: current date and quantity field."</title>
			<link>https://legacy.forums.gravityhelp.com/topic/dynamic-population-of-fields-by-2-variables-current-date-and-quantity-field#post-65947</link>
			<pubDate>Thu, 12 Jul 2012 10:10:34 +0000</pubDate>
			<dc:creator>JEWebDes</dc:creator>
			<guid isPermaLink="false">65947@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Chris or Shelly, where can I get a copy of the function you wrote to hide/display the full/reduced fee options based on date range.  That's exactly what I'm trying to do.  Thanks.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Shelly on "Dynamic population of fields by 2 variables: current date and quantity field."</title>
			<link>https://legacy.forums.gravityhelp.com/topic/dynamic-population-of-fields-by-2-variables-current-date-and-quantity-field#post-44662</link>
			<pubDate>Wed, 21 Dec 2011 09:30:50 +0000</pubDate>
			<dc:creator>Shelly</dc:creator>
			<guid isPermaLink="false">44662@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Well I guess I know what I'm putting in as a &#34;feature request&#34; then :)&#60;/p&#62;
&#60;p&#62;ETA: the suggestion above (creating fields and having them show using conditional logic based on what number is chosen in the dropdown) won't work, since I have variable conditions.  The &#34;how many&#34; dropdown is shown only if a previous choice is made - so when I start adding the extra fields, the fields all show, because I can't do a conditional statement along the lines of &#34;Show this field IF choice #1 is made AND when choice #2 is made OR choice #3 is made&#34;  So that won't fly.&#60;/p&#62;
&#60;p&#62;I guess I'll keep digging!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Chris Hajer on "Dynamic population of fields by 2 variables: current date and quantity field."</title>
			<link>https://legacy.forums.gravityhelp.com/topic/dynamic-population-of-fields-by-2-variables-current-date-and-quantity-field#post-44631</link>
			<pubDate>Wed, 21 Dec 2011 03:57:29 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">44631@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;No, Gravity Forms will not know about that field and will not process it.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Shelly on "Dynamic population of fields by 2 variables: current date and quantity field."</title>
			<link>https://legacy.forums.gravityhelp.com/topic/dynamic-population-of-fields-by-2-variables-current-date-and-quantity-field#post-44600</link>
			<pubDate>Tue, 20 Dec 2011 18:58:38 +0000</pubDate>
			<dc:creator>Shelly</dc:creator>
			<guid isPermaLink="false">44600@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Okay. Yeah, that won't work very well.  What about having a &#34;button&#34; added so you can &#34;add another field&#34; on the fly, using jQuery (example: &#60;a href=&#34;http://charlie.griefer.com/blog/jquery-dynamically-adding-form-elements/)?&#34; rel=&#34;nofollow&#34;&#62;http://charlie.griefer.com/blog/jquery-dynamically-adding-form-elements/)?&#60;/a&#62;  I see Gravity Forms doesn't do this now, but if I add a button with HTML input, will Gravity Forms pass the information?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Chris Hajer on "Dynamic population of fields by 2 variables: current date and quantity field."</title>
			<link>https://legacy.forums.gravityhelp.com/topic/dynamic-population-of-fields-by-2-variables-current-date-and-quantity-field#post-44565</link>
			<pubDate>Tue, 20 Dec 2011 17:14:04 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">44565@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;You can't modify a form dynamically based on an input like that.  You would have to create the fields in the form, then hide them with conditional logic.  Then you could have radio buttons with the numbers there, or a drop down, and then use conditional logic to unhide the proper number of additional text fields.  The problem with this approach is that it's not scalable.    And there are a lot of extra fields in your form.  If you have numbers from 1 to 9, it's not too bad.  If you're numbers are larger or unknown, it might not work.&#60;/p&#62;
&#60;p&#62;I think you might be able to work around it, but adding fields to a form based on a number input it not built into Gravity Forms.
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
