Skip Navigation

[Resolved] CRED Date field not working

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

Problem:
How to override the custom date field options on Toolset form

Solution:
To override the datepicker option for your custom date field as per your requirement, I've adjusted the JS code you have added to your form's JS box:

You can find the proposed solution, in this case with the following reply:
https://toolset.com/forums/topic/cred-date-field-not-working/#post-1217387

Relevant Documentation:

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

Tagged: 

This topic contains 4 replies, has 2 voices.

Last updated by Amin 5 years, 10 months ago.

Assisted by: Minesh.

Author
Posts
#1217221

I have created a simple form with just a date field.

I'm using jQuery to limit the date range. The date picker works fine with the jQuery script, but it doesn't save to the database. When I disable the script, it saves the date to the database.

Here is the jQuery script i'm using.

jQuery( document ).ready( function () {
// hidden link
jQuery( '.sitter-date' ).datepicker( {
changeYear: true,
yearRange: "-18:+0",
minDate: "-18y",
maxDate: 0
} );
} );

How can i use the script above and also have the date saved to the database?

FYI, I have a brand new wp install with only the default Twenty Ninteen theme and Types and CRED installed. Nothing else.

#1217387

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Well - to override the datepicker option for your custom date field as per your requirement, I've adjusted the JS code you have added to your form's JS box as given under:

jQuery(window).load(function() {
  id = jQuery('input[name="wpcf-sitter-date[display-only]"').attr('id');
    jQuery( "#"+id ).datepicker("option","yearRange","-18:+0");
    jQuery( "#"+id ).datepicker("option","minDate","-18y");
    jQuery( "#"+id ).datepicker("option","maxDate",0);
});   

I can see now it works as expected ?
=> hidden link

I'm offering you the exact solution you required but I just notice that you have added the comment to my profile which is contrary to the support I'm offering you here.

#1218123

Thanks for the quick response, Minesh. While the solution you provided works to add the date to the database, when I go back to edit the post (via cred edit form), the data is not being displayed.

You can replicate this by logging into the website and viewing any of the "sitters" posts from the front end. You'll see the cred edit form below the post details.

hidden link

The date is saved in the db and visible from the backend, but not on the frontend edit form.

Thanks in advance.

New threads created by Minesh and linked to this one are listed below:

https://toolset.com/forums/topic/split-custom-date-field-not-working-on-edit-post-form/

#1218344

Minesh
Supporter

Languages: English (English )

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

I've split the ticket for your edit form solution so that it will help other users searching on the forum.

Please feel free to resolve this ticket. I've shared the solution for Edit post form with the split ticket here:
=> https://toolset.com/forums/topic/split-custom-date-field-not-working-on-edit-post-form/#post-1218343

#1219142

My issue is resolved now. Thank you!