I am trying to customize the CREDs-Datepicker, but there are problems with saving the CRED-form. I assume, that the format of my date-fields causes the problem. Let me explain:
I have two required custom post type date-fields: a from-date (wpcf-anfr-anreise) and a to-date (wpcf-anfr-abreise). Without customizing the datepicker, these fields are showing up in a different time-format (= F d, Y) as my default wp-date-format (= d.m.Y). You can see that in my first screenshot.
But I have to customize the datepicker anyway, so that I can define a minDate and a maxDate based on the selected dates. If I'm calling the datepicker-function manually, then my default wp-date-format appears. But then the validation doesn't work. It always gives me an error, even though a date is selected (see 2nd screenshot).
I already figured out, that there are two different fields for each date-field: One [display-only]- and a hidden [datepicker]-field. I defined an altField [datepicker] in my datepicker-settings with the altFormat "@" (for timecode). The validation-errror-messages are gone - so far so good. Nevertheless after sending the form, there is an error-alert and the error-message on top are displaying. (screenshots 03a and 03b)
Just to mention it: If I don't define the timestamp-format "@" for the altField, then there are no errors. But my posts aren't showing any dates (screenshot 4).
I compared the default timestamp-value with my altField-value and noticed, that the default ones are given in seconds, my datepicker-values with predefined format "@" are in milliseconds. So I wrote an onSelect-handler for my datepicker, that fills in the correct timestamp-seconds in the [datepicker]-fields. That should work, shouldn't it?
No it's not. Now the validation is okay, but sending the form throws errors on top on both fields, and an error for the second date-field (unlike before for both of the fields) > see screenshot 4. Looking at my source-code, I can see, that the onSelect-handler works fine. But after selecting the second date, mysteriously the first hidden datepicker-field is switching back to the milliseconds-timestamp again.
Why is that? Is that a CRED-default setting or something like that? How can I get rid of that? Or do you know, how to define the standard-timestamp-format, so that it would show seconds instead of milliseconds? Or do you know a better way for storing the correct date-format into the database? Please for help!