简体   繁体   中英

How to use bootstrap datetimepicker in laravel edit form?

I am doing project in laravel. I have used bootstrap datetimepicker while editing form.

edit.blade looks like,

{!! Form::model($event,['method' => 'PATCH','files'=>true,'action'=>['EventController@update',$event->id]]) !!}
<div class="row" style="margin-bottom: 10px">
  <div class="col-sm-6">
     <label class="control-label">Start Date</label>
     <div class="input-group date form_date" data-date="" data-date-format="dd MM yyyy" data-link-field="dtp_input2" data-link-format="yyyy-mm-dd">
        <input class="form-control" size="16" type="text" name="start_date" value="{{$event_schedule->start_date or ''}}" readonly>
        <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
     </div>
    <input type="hidden" id="dtp_input2" value="" /><br/>
  </div>
  <div class="col-sm-6">
     <label class="control-label">End Date</label>
     <div class="input-group date form_date" data-date="" data-date-format="dd MM yyyy" data-link-field="dtp_input2" data-link-format="yyyy-mm-dd">
      <input class="form-control" size="16" type="text" name="end_date" value="{{$event_schedule->end_date or ''}}" readonly>
       <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
     </div>
   <input type="hidden" id="dtp_input2" value="" /><br/>
 </div>
</div>

{!!Forrm::close()!!}

when I submit this form and return request::all() from my controller method then does't return any date as result.

I don't know how to get this date so that I can edit form data.

I think you have to remove

 or ''

from value then you will get your date values using request.

try this,

 <input class="form-control" size="16" type="text" name="end_date" value="
 {{date('d-m-Y H:i:s',strtotime($event_schedule->end_date))}}" readonly>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM