Support Forum
Support › General › Time field "Done" button doesn't update field if slider/select not movedResolved
When using the time field (timepicker), if the user clicks the "Done" button without moving the time slider or select, the timepicker closes but the input is not populated with the time. So, if the user wants to select 12:00 am, they have to move the slider or change the select box at least once, even though 12:00 am is already selected. This appears to be a bug in the jquery-timepicker-addon that was never fixed and that project is no longer maintained.
Any ideas on how to fix this without having to edit the jquery-timepicker-addon code itself?
Hi,
The default value of the timepicker field is not populated. You need to select at least one box (hour or minute) to populate the time.
I will inform the development team to consider fixing this issue in future updates.
When the timepicker opens, 12:00 am is populated in the select boxes. The sliders default to 00:00 which is also 12:00 am. This bug has been noted in the GitHub Issues for the Datetimepicker project by other users dating back years and the issue was never fixed.
Hi Stephen,
You can try to set the default value of a field std
to save this value without selecting the time. Like this
'fields' => [
[
'name' => __( 'Time', 'your-text-domain' ),
'id' => $prefix . 'time',
'type' => 'time',
'std' => '00:00',
'js_options' => [
'hour' => 00,
'minute' => 00,
],
],
],
I ended up setting the beforeShow and onClose options along with adding an event listener (for the "Done" button), to make it function the way I want. Now, it functions this way: