I am looking for a way to dynamically populate a gravity forms time field using a hook that adds a predetermined number of hours to a starttime selected by the user filling out the form.
For example, if a user selects a 4 (number field) and then selects a start time of 6:30 than the end time is dynamically populated to be 10:30.
What I am ultimately looking for is a function for the functions.php file that will accurately create an endtime and an associated parameter to be placed in the 'allow this field to be dynamically populated' of a time-box on gravity forms
Additionally, I would want a function for the end date that, if the event goes past midnight. Then the enddate = startdate +1. This would also ultimately be a parameter for a datebox on a gravity forms to accompany the end time function
So if a user selects a 4 hour trip to start at 10:00pm then the end time would be 2:00am and the end date would be the next day.
This is based on the dynamic population ability of gravity forms http://www.gravityhelp.com/documentation/page/Using_Dynamic_Population
and is being used to select the endtime for an event ( http://anthonydispezio.com/blog/gf-ecp-frontend-submission/ ) based on a set event duration.
Hai Bui answers:
So, in the form, the user would only fill start time and start date, they don't need to see or fill the end date and end time, is that correct? You only want to populate the end date and end time for Events Calendar Pro? If that is the case, I can help you do that.
Let me know.
That's exactly what I am looking for. The user is selecting a 'service' that has an hour amount tied to it, and then picking when the service starts. The end time is only so it can be properly submitted to The Events Calendar Pro
Hai Bui comments: