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.

Populate field value on every page load

  1. I'm using gform_field_value_ to populate a form field value when the form is first rendered. I want to update that field value on every re-render/re-load. This might happen if the visitor fails to fill in required fields when they submit.

    Posted 7 years ago on Tuesday October 2, 2012 | Permalink
  2. Do you have an example of this form online now?

    When you say "update that field value on every reload", do you mean the value provided by your function will change, or do you want the same value you started with to be in that form field after a validation error, for example?

    Posted 7 years ago on Tuesday October 2, 2012 | Permalink
  3. The former. Say I populate it with date('YmdHis'). A visitor filing in the form at 12pm exactly (20121008120000) will keep resubmitting with that datetime on every subsequent resubmit. I want it to keep updating with whatever the datetime is at the point of resubmission.

    Posted 7 years ago on Monday October 8, 2012 | Permalink
  4. Sounds like you can use the gform_post_render jQuery hook to update the value after the form fails validation:
    http://www.gravityhelp.com/documentation/page/Gform_post_render

    This jQuery hook is fired every time the form is rendered to allow custom jQuery to be executed. This includes initial form load, going to the next/previous page on multi-page forms, form rendered with validation errors, confirmation message displayed, etc.

    Posted 7 years ago on Monday October 8, 2012 | Permalink
  5. So the only way to get a server side value in there is write some AJAX to fetch the data, and paste that whole jquery code block into an HTML form field?

    Seems like that's really going around the houses? Or did I miss something?

    Posted 7 years ago on Wednesday March 6, 2013 | Permalink
  6. This topic is pretty old. Can you explain what it is you're trying to do at this point? Maybe we can come up with another approach.

    Posted 7 years ago on Tuesday March 12, 2013 | Permalink