PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Dynamic Population of a date

  1. Hi there!

    I'am wondering if it is possible to dynamically populate a field with a date in the future. To be more specific: my clients will receive 2 weeks of support after they participate in a training. So I would like to create a field that automatically adds 2 weeks (or 14 days) to the date of the training.

    Is this possible? Thank you in advance!

    Posted 12 years ago on Wednesday July 18, 2012 | Permalink
  2. David Peralty

    Where will the initial date be coming from? Will there be a date field to select the start? If so, then it will require JS to dynamically show the end date two weeks later. If there will be a query string with the date attached to it. For example, you have a link like:
    http://www.example.com/course-signup/?start=18072012

    Then you would use the gform_pre_render hook and some PHP to grab that date, and create a date two weeks later, and put it in a form field before the form shows.

    http://www.gravityhelp.com/documentation/page/Gform_pre_render

    Posted 12 years ago on Wednesday July 18, 2012 | Permalink
  3. David Peralty

    Where will the initial date be coming from? Will there be a date field to select the start? If so, then it will require JS to dynamically show the end date two weeks later. If there will be a query string with the date attached to it. For example, you have a link like:
    http://www.example.com/course-signup/?start=18072012

    Then you would use the gform_pre_render hook and some PHP to grab that date, and create a date two weeks later, and put it in a form field before the form shows.

    http://www.gravityhelp.com/documentation/page/Gform_pre_render

    Posted 12 years ago on Wednesday July 18, 2012 | Permalink
  4. That looks difficult ;-) I'm not familiar with a lot of code writing and have no experience with JS of query strings...

    The date won't be selected in the form, since the form is only available for a specific date (I create a new form for every training, because I want to use the Entry Limit). So, I have to find a way to attach a date to the form (not visible for the visitor) and add 2 weeks to that.

    Posted 12 years ago on Wednesday July 18, 2012 | Permalink
  5. David Peralty

    Can you give me more information on why you need the date attached to the form? You could create admin only fields with default values in them. Thus, when you create the form for a specific training, you could have the start and end values already set as default in hidden fields. Would something like that work, or do you need it to be dynamic?

    Posted 12 years ago on Wednesday July 18, 2012 | Permalink
  6. Default values are ok, but I guess that means I have to adjust them for every form. So when I add a form for a training in another month, I have to adjust the start and end date. If I could automatically set the end date, it would make things a bit easier. However, it's no disaster if I have to do it manually.

    For the record, the end date is only for my own convenience, so I can view it in my Entry Management.

    Posted 12 years ago on Wednesday July 18, 2012 | Permalink