{{ Carbon::parse($workingtime->from)->format('h:i') }}
Populate a form (input type="date" or type="time") with data from the DB
This should be a simple question, however I do not find the answer anywhere.
I am building a simple Form that should be populated from the Data comming from the Database. The point here is that the data type from the columns from and to is Datetime.
I am using carbon in my application. Therefore I defined this in my Model
protected $dates = ['from', 'to'];
The form looks like this
<form method="POST" action="{{route('frontend.user.workingtimes.update', $workingtime->id )}}" accept-charset="UTF-8">
{{ csrf_field() }}
{{ method_field('PUT') }}
<input name="employee_id" type="hidden" value="{{ $workingtime->employee_id }}">
<label>@lang('labels.frontend.openinghours.from')</label>
<input class="form-control" type="time" value="{{ $workingtime->from->isoFormat('HH:mm') }}" name="from">
<label>@lang('labels.frontend.openinghours.to')</label>
<input class="form-control" type="time" value="{{ $workingtime->to->isoFormat('HH:mm') }}" name="to">
<button type="submit" class="btn btn-block btn-violeta mt-5">{{ ucfirst(__('labels.general.buttons.update')) }}</button>
</form>
I want to populate the form with the data comming from the DB, but there is not way that the data is shown directly in the input field (populated). I finnd always the answer when the <input type="text" but nowhere for <input type="date" or <input type="time"
Things like these, does not work:
<input type="time" value="{{ $workingtime->from->isoFormat('HH:mm') }}" name="from">
// or
<input type="time" value="{{ $workingtime->from }}" name="from">
How is the correct way?
Please or to participate in this conversation.