Display a timepicker. There are two styles to choose from. Popup and inline. The default is popup.
<x-bladewind::timepicker />
<x-bladewind::timepicker style="inline" />
By default the timepicker displays time in the 12 hour format. This format has hours from 1 to 12 and an AM/PM suffix.
To change this to a 24 hour format, set format="24"
. The 24 hour time format gets rid
of AM/PM suffix and displays the hours from 01 to 00. Note how the hours in 24 hour format are double digits.
<x-bladewind::timepicker format="24" />
<x-bladewind::timepicker style="inline" format="24" />
An asterisk is appended to the placeholder text when required="true"
.
<x-bladewind::timepicker required="true" />
<x-bladewind::timepicker label="HH:MM" required="true" />
<x-bladewind::timepicker style="inline" required="true" />
There are times you will want the timepicker to be prepopulated with a default time. This is useful when in edit mode.
To achieve this, set the selected
attribute to the time you will like to display.
The format of the time you set will depend on the format
defined on the timepicker.
<x-bladewind::timepicker selected_value="3:25PM" />
<x-bladewind::timepicker selected_value="03:25" format="24" />
<x-bladewind::timepicker style="inline" selected_value="3:25PM" />
<x-bladewind::timepicker style="inline" format="24" selected_value="03:25" />
<x-bladewind::timepicker
required="true"
style="inline"
format="24"
selected_value="03:25" />
Typically in a form, you should specify a name
for your timepicker component. A default random name is generated if no name is specified.
Let's assume in our
form the timepicker is named event_time
. An input is created with the name specified. In this case
event_time
.
When your form is submitted, you will be able to retrieve the time as shown below.
// if format="12" (default)
$request->event_time; // outputs 1:25PM
// if format="24"
$request->event_time; // outputs 01:25
The table below shows a comprehensive list of all the attributes available for the timepicker component.
Option | Default | Available Values |
---|---|---|
name | bw-timepicker | This name can be accessed when the input is submitted in the form. |
format | 12 | The format time should be displayed in. 12 24 |
selected_value | blank | In edit mode, the value passed will be set as the default time. |
hour_label | HH | Label to display for the hour dropdown. |
minute_label | MM | Label to display for the minute dropdown. |
format_label | -- | This applies only if using the inline timepicker. Label to display for the time format dropdown. |
placeholder | HH:MM | This applies only if using the popup style. Placeholder to display in the input field. |
label | blank | This applies only if using the popup style. Label to display in the input field. The label behaves just like in the BladewindUI Input component |
style | popup | Determines how to display the timepicker.popup inline |
required | false | Determines if the placeholder text should have an asterisk appended to it or not. Value needs to be set as a string not boolean.true false |
<x-bladewind.timepicker
name="start_time"
format="24"
required="false"
hour_label="hh"
minute_label="mm"
format_label="AM/PM"
placeholder="Start Time"
label="Start Time"
style="inline"
selected_value="12:35AM" />
resources > views > components > bladewind > timepicker.blade.php
lang/[lang]/timepicker.php