Why date form field is appearing with current date by default?

Why date form field is appearing with current date by default?

I have a page to edit the administrators of a post. This page has a form with some radio buttons, each radio button corresponds to an administrator.

I have this jQuery that receives an array with the administrators of a post from the controller and populate the details of each administrator in the form when the corresponding radio button is selected.

The issue is that, there is also a radio button "Create new admin" and when this radio button is clicked the form fields should reset. The issue is that using the moment plugin js to format the date when the "Create new administrator" radio button is selected all fields reset unless the date field, this date field appears with the current date.

Do you know why? 


jQuery:
 
  1.       $(document).ready(function () {
  2.              
  3.            var admins= {!!  $admin!!}
  4.         
  5.             $("input[name='radiobutton']").click(function() {
  6.                 let id = $(this).attr("id");
  7.                 let data = admins.find(e => e.id == id) || {
  8.                     name: "",
  9.                     date: "",
  10.                 };
  11.         
  12.                 //alert(data.date); 
  13.                 $("input[name='name']").val(data.name);
  14.                 ...
  15.                 $("input[name='date']").val(moment(data.date).format('DD MMMM YYYY h:mm'));
  16.     
  17.             });
  18.         });

Form:

  1.     <form method="post" class="clearfix" action="{{route('admins.update', ['id' => $post->id])}}" enctype="multipart/form-data">
  2.         {{csrf_field()}}
  3.         @foreach($administrators $admin)
  4.               <div class="form-check">
  5.                 <input class="form-check-input" type="radio" name="radiobutton" id="{{$admin->id}}" value="">
  6.                 <label class="form-check-label" for="">
  7.                   {{$admin->name}}
  8.                 </label>
  9.               </div>
  10.         @endforeach
  11.         <div class="form-check">
  12.           <input class="form-check-input" type="radio" name="radiobutton" id="create_administrator"
  13.                  value="option2">
  14.           <label class="form-check-label" for="exampleRadios2">
  15.               Create new administrator
  16.           </label>
  17.       </div>
  18.       <div class="form-group">
  19.         <label for="name">Name</label>
  20.         <input type="text" required class="form-control" value="{{ $admin->name }}" name="name">
  21.       </div>
  22.       <div class="input-group date" data-provide="datepicker">
  23.         <input type='text' name="date" value="{{ $admin->date->format('d F Y - H:i') }}"
  24.            class="form-control" placeholder="DD/MM/YYY" />
  25.         <span class="input-group-addon"><i class="fa fa-calendar text-primary" aria-hidden="true"></i></span>
  26.       </div>
  27.       <!-- below I have more form fields like administrator name, email, etc -->
  28.     
  29.       <input type="submit" id="adminStoreButton" class="btn btn-primary" value="Create"/>
  30.       <input type="submit" id="adminUpdateButton" class="btn btn-primary" value="Update"/>
  31.       </form>


Some debug notes:

- writing "moment(data.date).format('DD MMMM YYYY h:mm')" on the console it appears "referenceError: data is not defined"

- if I write moment() in the console it appears a moment object. Moment {_isAmomentObject...} so moment is defined

- alert(data) returns "[object Object]"

- alert(data.date) returns "2018-02-07 06:30:00"

- alert(Date(data.date)) shows the current date "Thu Mar 01.."

- alert(Date(data.date)) shows the current date "Thu Mar 01.." however the date field on the form is populated with the correct created date of the selected admin, it appears on the form field the created date of the selected admin: "07 February 2018 - 06:30", but in the alert appears the current date