nova-time-field
nova-time-field copied to clipboard
Nova 4 support
For Laravel Nova 4, try:
Text::make('Departure Time')->withMeta(['type' => 'time']),
Result:
`
Where you found it??? It works!
It was from some helpful folk in the nova channel on the Laravel Discord.
Glad it works for you too.
I see you found the Discord chat and also made an improvement for formatting. Posting here in case it is useful to anyone else:
Text::make('Departure Time')
->withMeta(['type' => 'time'])
->displayUsing(function($value) {
return Carbon::parse($value)->format('H:i');
}),
@sutcliffe121 Just a small edit to handle nullable, otherwise it display the current time as the value.
Text::make('Start time', 'start_time')->withMeta(['type' => 'time'])->displayUsing(function($value) {
return $value ? Carbon::parse($value)->format('H:i') : '—';
}),
With the Text field, I assume that we couldn't use options like minuteIncrement
, right?
@mrleblanc101 how to show in 24-hour format, it's showing in 12-hour format?
@teamappelit This is a native HTML Time input. It will use whatever is set in your OS.
@mrleblanc101 my Os is in 24 format but it still displaying in 12 hour AM/PM etc.