nova-time-field icon indicating copy to clipboard operation
nova-time-field copied to clipboard

Nova 4 support

Open meyer59 opened this issue 2 years ago • 9 comments

image

meyer59 avatar May 02 '22 13:05 meyer59

For Laravel Nova 4, try: Text::make('Departure Time')->withMeta(['type' => 'time']),

Result: image

`

sutcliffe121 avatar May 26 '22 19:05 sutcliffe121

Where you found it??? It works!

philipbaginski avatar May 28 '22 08:05 philipbaginski

It was from some helpful folk in the nova channel on the Laravel Discord.

Glad it works for you too.

sutcliffe121 avatar May 28 '22 08:05 sutcliffe121

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 avatar May 29 '22 07:05 sutcliffe121

@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') : '—';
}),

mrleblanc101 avatar Oct 12 '22 18:10 mrleblanc101

With the Text field, I assume that we couldn't use options like minuteIncrement, right?

bocanhcam avatar Jan 19 '24 02:01 bocanhcam

@mrleblanc101 how to show in 24-hour format, it's showing in 12-hour format?

teamappelit avatar Jan 31 '24 17:01 teamappelit

@teamappelit This is a native HTML Time input. It will use whatever is set in your OS.

mrleblanc101 avatar Jan 31 '24 22:01 mrleblanc101

@mrleblanc101 my Os is in 24 format but it still displaying in 12 hour AM/PM etc.

teamappelit avatar Feb 01 '24 08:02 teamappelit