templates/form/searchform.html.twig line 1

Open in your IDE?
  1. <div class="row mt-4">
  2.     <div class="col">
  3.         <div class="card card-body">
  4.             {{ form_start(form, { 'attr': {'class': 'row'} }) }}
  5.             <!--<form autocomplete="off" class="row" method="get" action="html/pages/all-spaces.html">-->
  6.             <div class="col-12 col-lg-5">
  7.                 <div class="form-group mb-lg-0">
  8.                     <div class="input-group input-group-lg mb-lg-0">
  9.                         <div class="input-group-prepend">
  10.                             <span class="input-group-text"><i class="fas fa-search"></i></span>
  11.                         </div>
  12.                         {{ form_widget(form.location, {'attr': {'class': 'form-control autocomplete', 'placeholder': 'Ville', 'onFocus' : 'geolocate()' }}) }}
  13.                     </div>
  14.                     {{ form_widget(form.locationhidden)}}
  15.                     {{ form_widget(form.placeid)}}
  16.                 </div>
  17.             </div>
  18.             <div class="col-12 col-lg-4">
  19.                 <div class="input-group input-group-lg mb-3 mb-lg-0">
  20.                     <div class="input-group-prepend">
  21.                         <span class="input-group-text"><i class="far fa-calendar-alt"></i></span>
  22.                     </div>
  23.                     {{ form_widget(form.date, {'attr': {'class': 'form-control datepicker', 'placeholder': 'Date', 'data-date-format':'dd/mm/yyyy'}}) }}
  24.                     <!--<input class="form-control datepicker" placeholder="Select date" type="text" required>-->
  25.                 </div>
  26.             </div>
  27.             <div class="col-12 col-lg-3">
  28.                 {{ form_widget(form.search, {'attr': {'class': 'btn btn-lg btn-primary btn-block mt-3 mt-md-0 animate-up-2' }} ) }}
  29.                 <!--<button class="btn btn-lg btn-primary btn-block mt-3 mt-md-0 animate-up-2" type="submit">Find a desk</button>-->
  30.             </div>
  31.             {{form_end(form)}}
  32.         </div>
  33.     </div>
  34. </div>
  35. <script>
  36.     var placeSearch, autocompleteinput;
  37.     var input = document.getElementById('festival_search_location');
  38.     var componentForm = {
  39.         street_number: 'short_name',
  40.         route: 'long_name',
  41.         locality: 'long_name',
  42.         administrative_area_level_1: 'short_name',
  43.         country: 'long_name',
  44.         postal_code: 'short_name'
  45.     };
  46.     function initAutocomplete() {
  47.         google.maps.event.addDomListener(input, 'blur', function() {
  48.             if (jQuery('.pac-item:hover').length === 0) {
  49.                 google.maps.event.trigger(this, 'focus', {});
  50.                 google.maps.event.trigger(this, 'keydown', {
  51.                     keyCode: 13
  52.                 });
  53.             }
  54.         })
  55.         // Create the autocomplete object, restricting the search to geographical
  56.         // location types.
  57.         autocompleteinput = new google.maps.places.Autocomplete(
  58.             /** @type {!HTMLInputElement} */
  59.             (input), {
  60.                 types: ['geocode']
  61.             });
  62.         // When the user selects an address from the dropdown, populate the address
  63.         // fields in the form.
  64.         autocompleteinput.addListener('place_changed', fillInAddress);
  65.     }
  66.     function fillInAddress() {
  67.         // Get the place details from the autocomplete object.
  68.         var place = autocompleteinput.getPlace();
  69.         if (place != null && place.place_id) {
  70.             //fill the hidden data
  71.             document.getElementById('festival_search_locationhidden').setAttribute('value', document.getElementById('festival_search_location').value)
  72.             document.getElementById('festival_search_placeid').setAttribute('value', place.place_id)
  73.         }
  74.     }
  75. </script>
  76. <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyArRqV6iNkruffZtVT2G0iX4kfemd1SQD4&libraries=places&callback=initAutocomplete&sessiontoken={{uuid}}" async defer></script>