auto-populate fields in gravity forms

In Gravity Forms plugin I’ve tried to dynamically populate End Date and End Time based on the Start Date and Start Time values.

This is the code I used to dynamically populate End Date:

[php]add_filter(“gform_field_value_date”, “populate_date”);
function populate_date($value){
return date(‘Y-m-d’, strtotime(’+0 days’));
}[/php]

This actually works but it adds ‘+0 days’ to the submission date and not to the ‘Start Date’ value.

Same goes with time. I want to have the ‘End Time’ field auto-populated, i.e. End Time = Start Time. And I want to add “+1 hour” to the ‘Start Time’ and thus get ‘End Time’.

Any suggestions? Tnx

I really don’t know what Gravity Forms plugin is doing, but for a guess I would say it’s using Variable variables http://php.net/manual/en/language.variables.variable.php. Meaning that populate_date is going to their own function (add_filter?) somewhere in the code and renaming the variable dynamically (look for the $$), I would look for it there and maybe you can modify it there? However, this is just a wild shot in the dark, maybe showing more code? Or maybe someone else here has a better suggestion?

Why are you changing the days parameter if it starts on the creation date?

[php]date(‘Y-m-d’, strtotime(’+0 days’));[/php]

[php]date(‘Y-m-d’);[/php]

Should accomplish what you are after without modification, judging by what the above would do.

Sponsor our Newsletter | Privacy Policy | Terms of Service