Skip Navigation

[Resolved] Datepicker defaults to last entered date

This thread is resolved. Here is a description of the problem and solution.

Problem:

How can we keep the custom field as a 'date' (for future filtering) and remove the date picker icon and functionality and add the date manually (like as if it was a text box).

Solution:

As a workaround, you can create another single line field, for example:

https://toolset.com/forums/topic/datepicker-defaults-to-last-entered-date/#post-2201309

Relevant Documentation:

This support ticket is created 3 years, 1 month 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by Adrian Robbins 3 years, 1 month ago.

Assisted by: Luo Yang.

Author
Posts
#2199669

We have a Repeatable Group of fields for the Tour Itinerary Days on a Tour Planning system we are developing.

The first field in the repeatable group is the Itinerary Day and we have this set as a Date field, with the standard calendar picker.

However it is rather slow to enter dates, as you first have to select the Year, then the Month and finally the day. This is OK for the first day, but some of the tours are very long with many days.

Is there a way, that having selected the date for the first day of the tour, when you enter the second day and so on, the calendar date picker 'remembers' the first day entered, which means you only have to select the day.

So, lets assume the first day is Thursday 14 July 2022, when you enter the second day in the tour, the calendar would already be set for July and 2022 and all you had to do was very quickly click on the 15th.

Many thanks

#2200449

Hello,

There isn't such kind of built-in feature within Toolset plugins, when you open a blank date picker, it should be current day.

In your case, you might consider other custom codes, it needs to get previous date value from Repeatable Group item, and setup the default value of datepicker, but according to our support policy we don't provide custom codes support.

Toolset is using jQuery UI datepicker to setup the custom date field, here is the document about "jQuery UI Datepicker":
hidden link
For your reference.

You can also check it with our Toolset contractors:
https://toolset.com/contractors/

#2200587

Hi Luo

Thank you for your advice.

How can we keep the custom field as a 'date' (for future filtering) and remove the date picker icon and functionality and add the date manually (like as if it was a text box).

Tried a few options from on Toolset forums and none of them seem to be working with the current versions of WordPress and/or toolset.

So, thats

1) Remove/hide little calendar icon
2) Allow a date field to have a manual entry

Many thanks for your help.

Kind regards
Ade

#2201309

Toolset custom date field stores value in timestamp format:
hidden link
I don't think it will be easier for your user to input the timestamp value

Both your request above is not available within Toolset plugins, you can submit a feature request for it:
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/
Our developers will evaluate it.

As a workaround, you can create another single line field, for example "my-text-date", when user create/edit the post, fill value into field in string format, save the post, use WP action hook save_post to trigger a PHP function:
https://developer.wordpress.org/reference/hooks/save_post/
In this custom PHP function, get the value from field "my-text-date":
https://developer.wordpress.org/reference/functions/get_post_meta/
Turn the value into timestamp format:
hidden link
And save it into your custom date field
https://developer.wordpress.org/reference/functions/update_post_meta/

for your reference.

#2201741

My issue is resolved now. Thank you!