Skip Navigation

[Escalated to 2nd Tier] Setting a default value for a date field based on another date field

This support ticket is created 5 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Author
Posts
#1322377

I have two date fields showing in a form (start-date and end-date).

I would like, when the start-date is chosen by the user, that the end date also shows this as a default value (until the user changes the end date if they do. Is this possible?

I have tried [cred_field field='end-date' force_type='field' class='form-control' output='bootstrap' value='$(start-date)']

#1322441

Hi, the only way to do this would be to use custom JavaScript that manipulates the datepicker options whenever the dates are changed. You can see examples of how other users solved similar problems with custom code:
https://toolset.com/forums/topic/disable-certain-datepicker-dates-depended-on-another-datepicker-value/
https://toolset.com/forums/topic/calendar-dates/
The datepicker documentation is available here: https://api.jqueryui.com/datepicker/

However, none of these methods seem to be perfect right now. Our 2nd tier team is currently investigating because there seem to be some issues when setting minDate and maxDate values if a date is already selected. There is also some discussion among our developers about other problems with the document "ready" event not being a reliable place to hook into. Sometimes more of a delay is needed, and perhaps a more reliable custom event hook. So until those things have been ironed out, there are some open issues to work around. I can link this ticket to the internal discussion tickets and keep you posted.

#1322453

Thanks Christian; that's helpful. Give the uncertainties, I will manage without for now.