Time value contract
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
The visible input uses the configured display format. The initialized picker submits a separate value under the original field name.
Values and form submission
Section titled “Values and form submission”| State | Visible text | Submitted value under the original input name |
|---|---|---|
| Valid time | Zero-padded HH:mm or HH:mm:ss, followed by a space and AM or PM when showMeridian is enabled | Zero-padded 24-hour HH:mm:ss |
| Empty time | Empty string | Empty string. The application can map it to null. |
| Invalid text | Original text | Original text, so the server can reject it. |
- Accept
HH:mmandHH:mm:ssas 24-hour input irrespective of display mode. Accepth:mm AMandh:mm:ss PMwith one or two hour digits and case-insensitive meridian. Ignore surrounding whitespace when parsing. Treat whitespace-only input as empty. For example,12:30and12:30 PMboth mean noon, and12:30 AMmeans00:30:00. - Read the browser-local hour, minute and second of a valid JavaScript
Date. An invalidDateleaves the current value untouched. A submitted time represents a wall-clock time without a date or timezone. - Keep supplied seconds even when
showSecondsis false. Initial values and explicitsetTimecalls without seconds use00. User edits to the displayed hours or minutes preserve the existing seconds when they are hidden. An edit starting from an empty or invalid value uses00if it supplies no seconds. Step settings affect stepping and the explicitcurrentdefault. Loading or typing a valid time keeps its precision. - Omitting
defaultTimeor setting it tofalseornullkeeps an empty field empty. Opening and closing without an edit preserves the value, including empty and invalid states. A configured default applies only to an initially empty input. SetdefaultTimetocurrentto populate an empty field with the local time. - Keep the original name for a standalone field or a Yii model attribute. Keep the visible input ID for labels and
existing selectors. A named, enabled widget contributes exactly one value to
FormData; a disabled or unnamed widget contributes none. Popup controls have no submitted names. Commit pending text when the field is left or the form is submitted. Server-side validation remains responsible for checking the submitted value. - Initialize the picker on an input that is already attached to the document. The hidden
data-timepicker-valuesibling that carries the submitted value and the popup are inserted next to the input and need a parent node, and a picker whose input is no longer in the document is released. Move or clone the visible input together with that sibling; an input moved or cloned alone leaves the submitted value behind. - Call
setTime,clear,showWidget,hideWidget,destroyandremovethrough the chainable.timepicker('method')dispatch, and readgetTime()from the instance in.data('timepicker').destroyandremoverestore the original name and the last submitted value to the visible input, and the field can be initialized again.
Events
Section titled “Events”- Initialize silently. A user action or API call that changes the effective value commits the visible field, the submitted value and the popup together before listeners run. An hour, minute or second rollover produces one final state, including when stepping forward or backward across midnight.
- Emit one
changeTime.timepickerfor a transition to a valid time or an empty value. Preserveevent.time.valueas the visible formatted value and addevent.time.canonicalValuefor the submitted value. Keep thehours,minutes,secondsandmeridianfields. Hours match the display mode, seconds include hidden precision, and meridian isnullin 24-hour mode. For an empty value both strings are empty and all four parts arenull. - Preserve the bubbling
changenotification once per effective edit, including an invalid text edit. Invalid text produces nochangeTime.timepickerevent. Reformatting equivalent input and opening or closing without an edit produce no plugin-generated change notifications. Keepshow.timepickerandhide.timepickerfor popup transitions.
See UPGRADE.md for migration from 1.x.