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.
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.
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?
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.
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.
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?
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.