I am seeing the following error when I try to submit a front-end entry form, but I cannot find the cause.

Object of class DateTime could not be converted to string

Below is the error result from my local installation. On production i just see a server error.

These errors started appearing after I restyled the form inputs with twitter's form controls. Has anyone here experienced an issue with this?

     yii\base\ErrorException: Object of class DateTime could not be converted to string in C:\MAMP\htdocs\immediate-start.dev\storage\runtime\compiled_templates\35\35f1a853a604b2243e72406d3ab2c91fef960885e297cd26008ba424e471986f.php:186
Stack trace:
#0 C:\MAMP\htdocs\immediate-start.dev\vendor\craftcms\cms\src\web\ErrorHandler.php(76): yii\base\ErrorHandler->handleError(4096, 'Object of class...', 'C:\\MAMP\\htdocs\\...', 186)
#1 C:\MAMP\htdocs\immediate-start.dev\storage\runtime\compiled_templates\35\35f1a853a604b2243e72406d3ab2c91fef960885e297cd26008ba424e471986f.php(186): craft\web\ErrorHandler->handleError(4096, 'Object of class...', 'C:\\MAMP\\htdocs\\...', 186, Array)
#2 C:\MAMP\htdocs\immediate-start.dev\vendor\twig\twig\lib\Twig\Template.php(390): __TwigTemplate_f4d1671377af0cebe39cc592268c76c3a4fb0218e42e460d1a8dfc65beb2b0e1->doDisplay(Array, Array)
#3 C:\MAMP\htdocs\immediate-start.dev\vendor\craftcms\cms\src\web\twig\Template.php(49): Twig_Template->displayWithErrorHandling(Array, Array)
#4 C:\MAMP\htdocs\immediate-start.dev\vendor\twig\twig\lib\Twig\Template.php(367): craft\web\twig\Template->displayWithErrorHandling(Array, Array)
#5 C:\MAMP\htdocs\immediate-start.dev\vendor\craftcms\cms\src\web\twig\Template.php(31): Twig_Template->display(Array, Array)
#6 C:\MAMP\htdocs\immediate-start.dev\storage\runtime\compiled_templates\d0\d0238043510d40e427d30c88249126d30874610a164b9994e04697a1c9847bd7.php(71): craft\web\twig\Template->display(Array)
#7 C:\MAMP\htdocs\immediate-start.dev\vendor\twig\twig\lib\Twig\Template.php(189): __TwigTemplate_3e33ad607d7b76dffd2875d5bc71a294a0f292bf2bddf1629be3507bcd21693c->block_main(Array, Array)
#8 C:\MAMP\htdocs\immediate-start.dev\storage\runtime\compiled_templates\a7\a7529b07d175f465339163b6770ac26d6db8d3ba5e2032ac5b705b49d41c12a1.php(52): Twig_Template->displayBlock('main', Array, Array)
#9 C:\MAMP\htdocs\immediate-start.dev\vendor\twig\twig\lib\Twig\Template.php(189): __TwigTemplate_e7457f8e41f2924b255bd120045603e01472ac06fd9903f34f0105780b260456->block_body(Array, Array)
#10 C:\MAMP\htdocs\immediate-start.dev\storage\runtime\compiled_templates\80\803274d11ab15ae9cb9388e3f6b238e4589016a6157e8bc820125d0e663bb4e9.php(45): Twig_Template->displayBlock('body', Array, Array)
#11 C:\MAMP\htdocs\immediate-start.dev\vendor\twig\twig\lib\Twig\Template.php(390): __TwigTemplate_273c2f73b09cc44b7355e3dd2049b6ee1ac46b62a46e1c0910d73665d848f2af->doDisplay(Array, Array)
#12 C:\MAMP\htdocs\immediate-start.dev\vendor\craftcms\cms\src\web\twig\Template.php(49): Twig_Template->displayWithErrorHandling(Array, Array)
#13 C:\MAMP\htdocs\immediate-start.dev\vendor\twig\twig\lib\Twig\Template.php(367): craft\web\twig\Template->displayWithErrorHandling(Array, Array)
#14 C:\MAMP\htdocs\immediate-start.dev\vendor\craftcms\cms\src\web\twig\Template.php(31): Twig_Template->display(Array, Array)
#15 C:\MAMP\htdocs\immediate-start.dev\storage\runtime\compiled_templates\a7\a7529b07d175f465339163b6770ac26d6db8d3ba5e2032ac5b705b49d41c12a1.php(34): craft\web\twig\Template->display(Array, Array)
#16 C:\MAMP\htdocs\immediate-start.dev\vendor\twig\twig\lib\Twig\Template.php(390): __TwigTemplate_e7457f8e41f2924b255bd120045603e01472ac06fd9903f34f0105780b260456->doDisplay(Array, Array)
#17 C:\MAMP\htdocs\immediate-start.dev\vendor\craftcms\cms\src\web\twig\Template.php(49): Twig_Template->displayWithErrorHandling(Array, Array)
#18 C:\MAMP\htdocs\immediate-start.dev\vendor\twig\twig\lib\Twig\Template.php(367): craft\web\twig\Template->displayWithErrorHandling(Array, Array)
#19 C:\MAMP\htdocs\immediate-start.dev\vendor\craftcms\cms\src\web\twig\Template.php(31): Twig_Template->display(Array, Array)
#20 C:\MAMP\htdocs\immediate-start.dev\storage\runtime\compiled_templates\d0\d0238043510d40e427d30c88249126d30874610a164b9994e04697a1c9847bd7.php(33): craft\web\twig\Template->display(Array, Array)
#21 C:\MAMP\htdocs\immediate-start.dev\vendor\twig\twig\lib\Twig\Template.php(390): __TwigTemplate_3e33ad607d7b76dffd2875d5bc71a294a0f292bf2bddf1629be3507bcd21693c->doDisplay(Array, Array)
#22 C:\MAMP\htdocs\immediate-start.dev\vendor\craftcms\cms\src\web\twig\Template.php(49): Twig_Template->displayWithErrorHandling(Array, Array)
#23 C:\MAMP\htdocs\immediate-start.dev\vendor\twig\twig\lib\Twig\Template.php(367): craft\web\twig\Template->displayWithErrorHandling(Array, Array)
#24 C:\MAMP\htdocs\immediate-start.dev\vendor\craftcms\cms\src\web\twig\Template.php(31): Twig_Template->display(Array, Array)
#25 C:\MAMP\htdocs\immediate-start.dev\vendor\twig\twig\lib\Twig\Template.php(375): craft\web\twig\Template->display(Array)
#26 C:\MAMP\htdocs\immediate-start.dev\vendor\twig\twig\lib\Twig\Environment.php(289): Twig_Template->render(Array)
#27 C:\MAMP\htdocs\immediate-start.dev\vendor\craftcms\cms\src\web\View.php(331): Twig_Environment->render('dashboard/post', Array)
#28 C:\MAMP\htdocs\immediate-start.dev\vendor\craftcms\cms\src\web\View.php(378): craft\web\View->renderTemplate('dashboard/post', Array)
#29 C:\MAMP\htdocs\immediate-start.dev\vendor\craftcms\cms\src\web\Controller.php(155): craft\web\View->renderPageTemplate('dashboard/post', Array)
#30 C:\MAMP\htdocs\immediate-start.dev\vendor\craftcms\cms\src\controllers\TemplatesController.php(78): craft\web\Controller->renderTemplate('dashboard/post', Array)
#31 [internal function]: craft\controllers\TemplatesController->actionRender('dashboard/post', Array)
#32 C:\MAMP\htdocs\immediate-start.dev\vendor\yiisoft\yii2\base\InlineAction.php(57): call_user_func_array(Array, Array)
#33 C:\MAMP\htdocs\immediate-start.dev\vendor\yiisoft\yii2\base\Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#34 C:\MAMP\htdocs\immediate-start.dev\vendor\craftcms\cms\src\web\Controller.php(103): yii\base\Controller->runAction('render', Array)
#35 C:\MAMP\htdocs\immediate-start.dev\vendor\yiisoft\yii2\base\Module.php(528): craft\web\Controller->runAction('render', Array)
#36 C:\MAMP\htdocs\immediate-start.dev\vendor\craftcms\cms\src\web\Application.php(282): yii\base\Module->runAction('templates/rende...', Array)
#37 C:\MAMP\htdocs\immediate-start.dev\vendor\yiisoft\yii2\web\Application.php(103): craft\web\Application->runAction('templates/rende...', Array)
#38 C:\MAMP\htdocs\immediate-start.dev\vendor\craftcms\cms\src\web\Application.php(271): yii\web\Application->handleRequest(Object(craft\web\Request))
#39 C:\MAMP\htdocs\immediate-start.dev\vendor\yiisoft\yii2\base\Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#40 C:\MAMP\htdocs\immediate-start.dev\web\index.php(21): yii\base\Application->run()
#41 {main}

Here is my dashboard/post template code:

    <div class="col-md-12">
{% macro errorList(errors) %}
    {% if errors %}
        <ul class="errors">
            {% for error in errors %}
                <li>{{ error }}</li>
            {% endfor %}
        </ul>
    {% endif %}
{% endmacro %}

{% from _self import errorList %}
<!--Job entry form-->

<form method="post" accept-charset="UTF-8">
    {{ csrfInput() }}
    <input type="hidden" name="action" value="entries/save-entry">
    {{ redirectInput('payment') }}
    <input type="hidden" name="sectionId" value="1">
    <input type="hidden" name="enabled" value="1">

<h2>Job Details</h2>

<!--Title and Location Row-->

    <!--Job title-->
    <div class="row">
      <div class="col form-group">
          <label for="title">Title</label>
          <input class="form-control" id="title" type="text" name="title" required
              {%- if entry is defined %} value="{{ entry.title }}"{% endif -%} >

          {% if entry is defined %}
              {{ errorList(entry.getErrors('title')) }}
          {% endif %}

      </div>
    <!--Location-->
        <div class="col form-group">
          <label for="Location">Location</label>
          <input class="form-control" id="autocomplete" onFocus="geolocate()" type="text" name="fields[jobLocation]" required placeholder="Enter job location" 
          {%- if entry is defined %} value="{{ entry.jobLocation }}"{% endif -%}>

          {% if entry is defined %}
              {{ errorList(entry.getErrors('jobLocation')) }}
          {% endif %}

             <table id="address">
              <tr>
                <td><input hidden name="fields[jobLocation][street1]" id="street_number" disabled="true"></input></td>
                <td><input hidden name="fields[jobLocation][street2]" id="route" disabled="true"></input></td>
              </tr>
              <tr>
                <td><input hidden id="postal_town" name="fields[jobLocation][city]" disabled="true"></input></td>
              </tr>
              <tr>
                <td><input hidden name="fields[jobLocation][state]" id="administrative_area_level_1" disabled="true"></input></td>
                <td><input hidden id="postal_code" name="fields[jobLocation][zip]" disabled="true"></input></td>
              </tr>
              <tr>
                <td><input hidden name="fields[jobLocation][country]" id="country" disabled="true"></input></td>
              </tr>
              <tr>
                <td><input hidden name="fields[jobLocation][lat]" id="lat" disabled="true" value=""></input></td>
              </tr>
              <tr>
                <td><input hidden name="fields[jobLocation][lng]" id="lng" disabled="true" value=""></input></td>
              </tr>
              </table>
        </div>
</div>
<!-- job description-->
<div class="form-group">
      <label for="description">Job Description</label>
      <textarea class="form-control" id="description" name="fields[description]" placeholder="Job description" rows="15" required>
          {%- if entry is defined %}{{ entry.description }}{% endif -%}
      </textarea>

      {% if entry is defined %}
          {{ errorList(entry.getErrors('description')) }}
      {% endif %}
</div>


      <!--Hiring organisation-->
    <div class="row">
        <div class="col form-group">
          <label for="hiringOrganisation">Hiring company</label>
          {% set recruiterOptions = craft.entries.section('recruiters').authorId(loggedInUserID).all() %}
          <select class="form-control" required name="fields[hiringOrgansation][]" id="hiringOrganisation">
            <option value="" disabled selected>Choose your option</option>
            {% for entry in recruiterOptions %}
            <option value="{{ entry.title }}">{{ entry.title }}</option>
            {% endfor %}
          </select>

       </div>



           <!-- Expiry date-->
    <div class="col form-group">
        <label for="validThrough">Job expiry date</label>
        <input class="form-control" required type="date" placeholder="Enter job ad expiry date" name="fields[validThrough]" id="validThrough" {%- if entry is defined %} value="{{ entry.validThrough }}"{% endif -%}>

        {% if entry is defined %}
        {{ errorList(entry.getErrors('validThrough')) }}
        {% endif %}

    </div>

    </div>

    <div class="row">
      <!-- Recruiters logo -->
      <div class="col form-group">
          <label for="recruiterLogo">Hiring company's logo</label>
          <input class="form-control-file" type="file" name="fields[recruiterLogo]" id="recruiterLogo">
      </div>

      <!-- Recruiters Image -->

      <div class="col form-group">
          <label for="jobimage">Job Image</label>
          <input class="form-control-file" type="file" name="fields[jobimage]" id="jobimage">
      </div>
</div>

<!--Occupatonal categories and Industry row-->

  <!--Occupatonal categories-->
  <div class="row">
      <div class="col form-group">
  <label for="occupationalCategory">Category</label>
  {% set occCategories = craft.categories.group('occupationalCategory').all() %}
  <select class="form-control" required name="fields[occupationalCategory][]" placeholder="Select category" id="occupationalCategory">
      <option value="" disabled selected>Select Occupation</option>
    {% for category in occCategories %}
       <option value="{{category.id}}">
         {{category}}
       </option>
   {% endfor %}
  </select>
</div>
  <!-- Industry-->
  <div class="col">
  <label for="industry">Industry</label>
  {% set industries = craft.categories.group('industry').all() %}
  <select class="form-control" required name="fields[industry][]" placeholder="Select industry" id="industry">
      <option value="" disabled selected>Select Industry</option>

    {% for category in industries %}
       <option value="{{category.id}}">
         {{category}}
       </option>
   {% endfor %}
  </select>
</div>
</div>

<!-- Working hours -->

<div class="form-group border p-1">
  <p>Working Hours</p>
  <div class="form-check form-check-inline">
    <input class="form-check-input" type="hidden" name="fields[workHours]" value="">
    <label for="WorkHours">Work Hours</label>
  </div>

  <div class="form-check form-check-inline">
    <input class="form-check-input" type="checkbox" name="fields[workHours][]" id="9to5" value="9to5">
    <label class="form-check-label" for="9to5">9 to 5</label>
  </div>

  <div class="form-check form-check-inline">
    <input class="form-check-input" type="checkbox" name="fields[workHours][]" value="flexible">
    <label class="form-check-label" for="flexible">flexible</label>
  </div>
  <div class="form-check form-check-inline">
    <input class="form-check-input" type="checkbox" name="fields[workHours][]" value="nightShift">
    <label class="form-check-label" for="nightShift">nightShift</label>
  </div>

  <div class="form-check form-check-inline">
    <input class="form-check-input" type="checkbox" name="fields[workHours][]" value="mornings">
    <label class="form-check-label" for="mornings">mornings</label>
  </div>

  <div class="form-check form-check-inline">
  <input class="form-check-input" type="checkbox" name="fields[workHours][]" value="evenings">
  <label class="form-check-label" for="evenings">evenings</label>
  </div>
  <div class="form-check form-check-inline">
  <input class="form-check-input" type="checkbox" name="fields[workHours][]" value="afternoons">
  <label class="form-check-label" for="afternoons">afternoons</label>
  </div>
</div>


  <!--- Employment Type -->
  <input type="hidden" name="fields[employmentType]" value="">
  <div class="form-group border p-1">
    <p>Employment Type</p>
    <div class="form-check form-check-inline">
    <input type="hidden" name="fields[employmentType]" value="">
    <label class="form-check-label" for="afternoons">afternoons</label>
    </div>
  <div class="form-check form-check-inline">
    <input class="form-check-input" type="checkbox" name="fields[employmentType][]" value="fullTime">
    <label class="form-check-label" for="fullTime">Full-time</label>
  </div>
  <div class="form-check form-check-inline">
    <input class="form-check-input" type="checkbox" name="fields[employmentType][]" value="partTime">
    <label class="form-check-label" for="partTime">Part-time</label>
  </div>
  <div class="form-check form-check-inline">
    <input class="form-check-input" type="checkbox" name="fields[employmentType][]" value="contract">
    <label class="form-check-label" for="contract">Contract</label>
  </div>
  <div class="form-check form-check-inline">
    <input class="form-check-input" type="checkbox" name="fields[employmentType][]" value="temporary">
    <label class="form-check-label" for="temporary">Temporary</label>
  </div>
  <div class="form-check form-check-inline">
    <input class="form-check-input" type="checkbox" name="fields[employmentType][]" value="seasonal">
    <label class="form-check-label" for="seasonal">Seasonal</label>
  </div>
  <div class="form-check form-check-inline">
    <input class="form-check-input" type="checkbox" name="fields[employmentType][]" value="internship">
    <label class="form-check-label" for="internship">Internship</label>
  </div>

</div>

  <h2>Salary and Benefits</h2>

<!-- Salary and Benefits-->
  <!--salaryCurrency-->

  <div class="row">
    <div class="col-md-2 form-group">
      <label for="salaryCurrency">Currency</label>
        <select class="form-control" name="fields[salaryCurrency]" placeholder="Select salary currency" id="salaryCurrency" {%- if entry is defined %} value="{{ entry.salaryCurrency }}" {% endif -%}>
          <option selected value="GBP">£ GBP</option>
          <option value="EUR">€ EUR</option>
          <option value="USD">$ USD</option>
        </select>
        {% if entry is defined %}
        {{ errorList(entry.getErrors('salaryCurrency')) }}
        {% endif %}
</div>
  <!--Salary amount-->
  <div class="col-md-4 form-group">
        <label for="baseSalary">Hourly rate</label>
        <input class="form-control" type="number" placeholder="Enter hourly rate" name="fields[baseSalary]" id="baseSalary" required {%- if entry is defined %} value="{{ entry.baseSalary }}" {% endif -%}>
        {% if entry is defined %}
        {{ errorList(entry.getErrors('baseSalary')) }}
        {% endif %}
   </div>
  </div>


   <!-- Benefits-->
  <div class="row">
    <div class="col-md-6 form-group">
    <label for="jobBenefits">Benefits</label>
    <input class="form-control" type="text" placeholder="Enter job benefits" name="fields[jobBenefits]" id="jobBenefits" {%- if entry is defined %} value="{{ entry.jobBenefits }}" {% endif -%}>
    {% if entry is defined %}{{ errorList(entry.getErrors('jobBenefits')) }}{% endif %}
  </div>


  <!-- Incentives -->
  <div class="col form-group">
    <label for="incentiveCompensation">Incentives</label>
    <input class="form-control" type="text" placeholder="Enter incentives" name="fields[incentiveCompensation]" id="incentiveCompensation" {%- if entry is defined %} value="{{ entry.incentiveCompensation }}" {% endif -%}>
    {% if entry is defined %}{{ errorList(entry.getErrors('incentiveCompensation')) }}{% endif %}
    </div>
</div>



<!-- Candidate requirements -->
<h2>Candidate Requirements</h2>

<div class="row">
  <!-- Required Experience -->
  <div class="col form-group">
    <label for="experienceRequirements">Required experience</label>
    <input class="form-control" type="text" placeholder="Enter required experience" name="fields[experienceRequirements]" id="experienceRequirements" {%- if entry is defined %} value="{{ entry.experienceRequirements }}" {% endif -%}>
    {% if entry is defined %}{{ errorList(entry.getErrors('experienceRequirements')) }}{% endif %}
  </div>

  <!-- Education Requirements -->
  <div class="col form-group">
    <label for="educationRequirements">Education requirements</label>
    <input class="form-control" type="text" placeholder="Enter education requirements" name="fields[educationRequirements]" id="educationRequirements" {%- if entry is defined %} value="{{ entry.educationRequirements }}" {% endif -%}>
    {% if entry is defined %}{{ errorList(entry.getErrors('educationRequirements')) }}{% endif %}
  </div>
</div>
  <!-- Qualifications-->
<div class="row">
<div class="col form-group">
    <label for="qualifications">Qualifications</label>
    <input class="form-control" type="text" placeholder="Enter required qualifications" name="fields[qualifications]" id="qualifications" {%- if entry is defined %} value="{{ entry.qualifications }}" {% endif -%}>
    {% if entry is defined %}{{ errorList(entry.getErrors('occupationalCategoryqualifications')) }}{% endif %}
</div>


  <!-- Responsibilities-->
<div class="col form-group">
  <label for="responsibilities">Responsibilities</label>
  <input class="form-control" type="text" placeholder="Enter job responsibilities" name="fields[responsibilities]" id="responsibilities" {%- if entry is defined %} value="{{ entry.responsibilities }}" {% endif -%}>
  {% if entry is defined %}{{ errorList(entry.getErrors('responsibilities')) }}{% endif %}
  </div>
</div>
  <!--Skills -->
<div class="row">
  <div class="col form-group">
    <label for="skills">Skills</label>
    <input class="form-control" type="text" placeholder="Enter required skills" name="fields[skills]" id="skills" {%- if entry is defined %} value="{{ entry.skills }}" {% endif -%}>{% if entry is defined %}{{ errorList(entry.getErrors('skills')) }}{% endif %}
  </div>

  <!-- Special Commitments-->
  <div class="col form-group">  
    <label for="specialCommitments">Special Commitments</label>
    <input class="form-control" type="text" placeholder="Enter any special commitments" name="fields[specialCommitments]" id="specialCommitments" {%- if entry is defined %} value="{{ entry.specialCommitments }}" {% endif -%}>{% if entry is defined %}{{ errorList(entry.getErrors('specialCommitments')) }}{% endif %}
  </div>
</div>

<!-- Application Methods-->
<h2>Managing Applications</h2>

  <!-- Application email address-->
<div class="row">
  <div class="col form-group">
    <label for="jobApplicationEmailAddress">Application email address</label>
    <input class="form-control" type="email" name="fields[jobApplicationEmailAddress]" id="jobApplicationEmailAddress" placeholder="Enter application email address" {%- if entry is defined %} value="{{ entry.jobApplicationEmailAddress }}" {% endif -%}>{% if entry is defined %}{{ errorList(entry.getErrors('jobApplicationEmailAddress')) }}{% endif %}
  </div>
  <!-- Application url-->

<div class="col form-group">
  <label for="jobApplicationRedirectUrl">Send candidates to a website</label>
    <div class="input-group">
        <div class="input-group-prepend">
          <span class="input-group-text" id="jobApplicationRedirectUrl">http://</span>
        </div>
        <input name="fields[jobApplicationRedirectUrl]" type="url" class="form-control" id="jobApplicationRedirectUrl" aria-describedby="basic-addon3" placeholder="Enter application website" {%- if entry is defined %} 
        value="{{entry.jobApplicationRedirectUrl }}" {% endif -%}>{% if entry is defined %}{{ errorList(entry.getErrors('jobApplicationRedirectUrl')) }}{% endif %}
  </div>
</div>
</div>
  <!-- application phone number-->
 <div class="row"> 
  <div class="col form-group">
    <label for="jobApplicationPhoneNumber">Application phone number</label>
    <input class="form-control" type="number" name="fields[jobApplicationPhoneNumber]" id="jobApplicationPhoneNumber" placeholder="Enter application phone number" {%- if entry is defined %} value="{{ entry.jobApplicationPhoneNumber }}" {% endif -%}>{% if entry is defined %}{{ errorList(entry.getErrors('jobApplicationPhoneNumber')) }}{% endif %}
  </div>

  <!-- whatsapp phone number-->

      <div class="col form-group">
        <label for="whatsappNumber">WhatsApp Number</label>
        <input class="form-control" type="number" name="fields[whatsappNumber]" id="whatsappNumber" placeholder="Enter application phone number" {%- if entry is defined %} value="{{ entry.jobApplicationPhoneNumber }}" {% endif -%}>{% if entry is defined %}{{ errorList(entry.getErrors('whatsappNumber')) }}{% endif %}
      </div>
</div>

<div class="row">
          <!-- Hiring Contact -->
          <div class="col-md-6 form-group">
            <label for="recruiterPrimaryContact">Primary contact</label>
            <input class="form-control" type="text" placeholder="Enter name of primary Contact" name="fields[recruiterPrimaryContact]" id="recruiterPrimaryContact" required {%- if entry is defined %} value="{{ entry.recruiterPrimaryContact }}" {% endif -%}>{% if entry is defined %}{{ errorList(entry.getErrors('recruiterPrimaryContact')) }}{% endif %}
          </div>
</div>

<input class="btn btn-primary" type="submit" value="Submit">
</form>
</div>

<script>
    var placeSearch, autocomplete;
    var componentForm = {
      street_number: 'short_name',
      route: 'long_name',
      postal_town: 'long_name',
      administrative_area_level_1: 'short_name',
      country: 'long_name',
      postal_code: 'short_name',
      lat: 'long_name',
      lng: 'long_name'
    };

    function initAutocomplete() {
      // Create the autocomplete object, restricting the search to geographical
      // location types.
      autocomplete = new google.maps.places.Autocomplete(
          /** @type {!HTMLInputElement} */(document.getElementById('autocomplete')),
          {types: ['geocode']});

      // When the user selects an address from the dropdown, populate the address
      // fields in the form.
      autocomplete.addListener('place_changed', fillInAddress);
    }

    function fillInAddress() {
      // Get the place details from the autocomplete object.
      var place = autocomplete.getPlace();

      for (var component in componentForm) {
        document.getElementById(component).value = '';
        document.getElementById(component).disabled = false;
      }

      // Get each component of the address from the place details
      // and fill the corresponding field on the form.
      for (var i = 0; i < place.address_components.length; i++) {
        var addressType = place.address_components[i].types[0];
        if (componentForm[addressType]) {
          var val = place.address_components[i][componentForm[addressType]];
          document.getElementById(addressType).value = val;
          document.getElementById('lat').value = place.geometry.location.lat();
          document.getElementById('lng').value = place.geometry.location.lng();
        }
      }
    }


    // Bias the autocomplete object to the user's geographical location,
    // as supplied by the browser's 'navigator.geolocation' object.
    function geolocate() {
      if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(function(position) {
          var geolocation = {
            lat: position.coords.latitude,
            lng: position.coords.longitude
          };
          var circle = new google.maps.Circle({
            center: geolocation,
            radius: position.coords.accuracy
          });
          autocomplete.setBounds(circle.getBounds());
        });
      }
    }
  </script>
  <script src="https://maps.googleapis.com/maps/api/js?key=[ **removed** ] &libraries=places&callback=initAutocomplete"
   async defer></script>
  </article>
  • It seems your dashboard/post has this error or a template it includes. – Robin Schambach Oct 11 at 5:13
  • Can you share the form template code along with the values you're submitting? – Brad Bell Oct 11 at 5:16
  • Thank you both! Brad I've added the template code - sorry it's quite a huge form! When I've tried to submit to the text only fields it has worked, but including values for check-boxes, or urls/phone numbers for the application methods at the end cause the error mentioned above. – Paddy Dewhurst Oct 14 at 22:31

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.