Skip Navigation

[Resolved] input – Default Date

This support ticket is created 4 years, 2 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
- 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)

This topic contains 14 replies, has 2 voices.

Last updated by Minesh 4 years, 2 months ago.

Assisted by: Minesh.

Author
Posts
#1781083
expect.jpg
current.jpg

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;
}
#1781255

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

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.

#1781293

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

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.

#1781299

I made mistake,
URL is

hidden link

Sorry about that

#1781385

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

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.

#1781397

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?

#1781413

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

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.

#1781417
error.jpg

The date was saved, but a strange date was entered. Attach a screenshot. The date is 5268-07-07, not today's date.

#1781445

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

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.

#1781451

hidden link

here is admin page link, Thanks

#1781453

Should login with "paul"

#1781457

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

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.

#1781461

My issue is resolved now. Thank you! You are so amazing. Thank you a lot, Have a nice weekend.

#1783619

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/

#1783625

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

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.