Skip Navigation

[Résolu] CSS issue in datepicker UI and default date.

This support ticket is created Il y a 4 années et 1 mois. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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 3 réponses, has 2 voix.

Last updated by Luo Yang Il y a 4 années et 1 mois.

Assisted by: Luo Yang.

Auteur
Publications
#1491161
firefox_2020-02-03_22-44-57.png

I've noticed that in the date picker the CSS is not applied correctly - see image.

I think it's something to do with this:
.ui-datepicker tr:first-child {
border: 1px solid
#27292b;
}
Could that just not be applied to the thead?

Also, could a custom date field display a default date in the backend, to save repeatedly picking today? It has today pre-selected when you click to pick a date, but it'd be good if it displayed it without having to click.

#1491525

Hello,

Q1) Could that just not be applied to the thead?
You can setup your CSS codes like this:

.ui-datepicker thead {
/**here add CSS codes... **/
}

Q2) could a custom date field display a default date in the backend, to save repeatedly picking today?
No, there isn't such kind of feature, it is required to click and pick a date, you might consider custom codes, for example:
https://stackoverflow.com/questions/46448877/jquery-datepicker-set-initial-date

#1491875

Q1) Yes I thought there was a problem with your CSS but it may be a theme/plugin over-riding.

Q2) I couldn't get the jquery to work. I have used the code below and added to my functions.php which does seem to work. Is this OK? It only works for the first time of data entry but when my client is doing a bulk lot of data entry but it can be useful.

 /* Set Today's Date Initial Entry */
function set_date_field( $post_id ) {
    $date = get_post_meta($post_id, 'wpcf-your-date');
    if(empty($date)){
        update_post_meta($post_id, 'wpcf-your-date','today');
    }
}   
add_action( 'save_post', 'set_date_field' );

Discovered the above wouldn't save as we need to use unix timestamp, whereas the below saved fine. Can you confirm the code is OK?

/* Set Today's Date for Policy Date */
function set_date_field( $post_id ) {
    $date = get_post_meta($post_id, 'wpcf-policy-date');
	$now = time(); // Current time and date as a timestamp
    if(empty($date)){
        update_post_meta($post_id, 'wpcf-policy-date', $now);
    }
}   
add_action( 'save_post', 'set_date_field' );
#1493027

I think your new PHP codes are OK.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.