0

I would like to change the date of birth for a field, however when I click on the button edit, the value of the date of birth is empty.

Here is an example

index.blade

enter image description here

edit.blade

enter image description here

The value is empty...

I have tried this:

<fieldset class="form-group">
<label for="form-group-input-1">Date naissance</label>
<input type="date" name="date_naissance" class="form-control" id="form-group-input-1" value="{{$eleves->date_naissance}}">
</fieldset>

Thank you!

user11124425
  • 961
  • 1
  • 11
  • 22

1 Answers1

3

That's quite simple. your value date should have a format... And the edit will work if you have it on a form, ect...

value="{{$eleves->date_naissance->format('Y-m-d')}}"

change this:

<input type="date" name="date_naissance" class="form-control" id="form-group-input-1" value="{{$eleves->date_naissance}}">
</fieldset>

to this:

<input type="date" name="date_naissance" class="form-control" id="form-group-input-1" value="{{$eleves->date_naissance->format('Y-m-d')}}">
</fieldset>

Test it and let me know.

mindmaster
  • 1,828
  • 12
  • 22