user11124425
user11124425

Reputation: 971

Get the value of the date when I edit a input

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!

Upvotes: 0

Views: 1205

Answers (1)

mindmaster
mindmaster

Reputation: 1888

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.

Upvotes: 3

Related Questions