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