Home › Toolset Professional Support › [Resolved] input – Default Date
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 |
---|---|---|---|---|---|---|
- | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10: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/Kolkata (GMT+05:30)
Tagged: Content-submission forms, Toolset Forms
Related documentation:
This topic contains 14 replies, has 2 voices.
Last updated by Minesh 4 years, 2 months ago.
Assisted by: Minesh.
Tell us what you are trying to do?
Last time I succeeded in entering the last date in the repeating field on view with Minesh's help.
(https://toolset.com/forums/topic/display-limit-number-of-in-repeating-field-on-view/)
In addition, my customer wants one more thing, but I want to pre-enter today's date by default in the input date field.
I searched the toolset site to enter the dafault date,
I found this function and applied it.
https://toolset.com/forums/topic/set-today-as-default-for-a-datepicker/
However, this function has a problem.
When I enter today date, all previously entered dates are deleted and only today date remains.
Is there any way to solve this problem?
Attach photos to help you understand.
The first image is an existing form, and the second image is the form I want.
Is there any documentation that you are following?
https://toolset.com/forums/topic/set-today-as-default-for-a-datepicker/
Is there a similar example that we can see?
What is the link to your site?
hidden link
I added this code
add_shortcode( 'format-date', 'format_date_func'); function format_date_func($atts) { $a = shortcode_atts( array( 'format' => 'U', 'timestamp' => date('U'), ), $atts ); $date = date($a['format'], $a['timestamp']); return $date; }
Hello. Thank you for contacting the Toolset support.
Can you please send me access details so I can add the JS code that will set the today's date to your date picket.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
Again, just like the previous ticket, when I login and try to access your page: hidden link
I can see the message "No items found ". Can you please send me user access details using which I can see those datepicker fields.
I have set the next reply to private which means only you and I have access to it.
I made mistake,
URL is
hidden link
Sorry about that
Can you please check now: hidden link
I've adjusted the code to your form's JS editor as given under:
jQuery(window).load(function(){ jQuery("div.js-wpt-field-items").each(function(){ jQuery(this).find('div.wpt-repctl-flex:not(:last)').remove(); jQuery(this).find("a.js-wpt-repadd").trigger("click"); var $dp = jQuery(this).find('div.wpt-repctl-flex:last').find(".js-wpt-date"); $dp.datepicker('option', 'dateFormat', 'yy-mm-dd' ); $dp.datepicker("setDate", new Date()); }); });
Can you please confirm the default date is set now as today's date.
I tested the page and today's date is displayed correctly on the UI, but when I click the "Submit" button, it doesn't actually save. Can you check it again?
Can you please check now.
I've added the following line of code to your form's JS editor:
jQuery(this).find('div.wpt-repctl-flex:last').find(".wpt-form-hidden").val(jQuery.now());
It should be ok now. Can you please confirm.
The date was saved, but a strange date was entered. Attach a screenshot. The date is 5268-07-07, not today's date.
Can you please share the admin link where i can find those post that I'm editing from the frontend.
I mean on what page I can see in admin that where those values have been saved? And where I can see on frontend for which you shared the screenshot.
hidden link
here is admin page link, Thanks
Should login with "paul"
Can you please check now: hidden link
I've adjusted the JS code as given under:
jQuery(window).load(function(){ jQuery("div.js-wpt-field-items").each(function(){ jQuery(this).find('div.wpt-repctl-flex:not(:last)').remove(); jQuery(this).find("a.js-wpt-repadd").trigger("click"); var $dp = jQuery(this).find('div.wpt-repctl-flex:last').find(".js-wpt-date"); $dp.datepicker('option', 'dateFormat', 'yy-mm-dd' ); $dp.datepicker("setDate", new Date()); current_time = parseInt((jQuery.now()/1000)); jQuery(this).find('div.wpt-repctl-flex:last').find(".wpt-form-hidden").val(current_time); }); });
I can see now its displaying the correct date. Can you please confirm.
My issue is resolved now. Thank you! You are so amazing. Thank you a lot, Have a nice weekend.
I found a new error. Only two days of attendance are saved. If you enter the third attendance date, the oldest attendance date is deleted, and only the second of the latest attendance dates remains in the record.
New threads created by Minesh and linked to this one are listed below:
https://toolset.com/forums/topic/split-input-default-date-old-date-not-working/
Hi HansooH:
I've split the ticket and will communicate with you there:
=> https://toolset.com/forums/topic/split-input-default-date-old-date-not-working/
Can you please follow above ticket.