<div class="row mt-4">
<div class="col">
<div class="card card-body">
{{ form_start(form, { 'attr': {'class': 'row'} }) }}
<!--<form autocomplete="off" class="row" method="get" action="html/pages/all-spaces.html">-->
<div class="col-12 col-lg-5">
<div class="form-group mb-lg-0">
<div class="input-group input-group-lg mb-lg-0">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fas fa-search"></i></span>
</div>
{{ form_widget(form.location, {'attr': {'class': 'form-control autocomplete', 'placeholder': 'Ville', 'onFocus' : 'geolocate()' }}) }}
</div>
{{ form_widget(form.locationhidden)}}
{{ form_widget(form.placeid)}}
</div>
</div>
<div class="col-12 col-lg-4">
<div class="input-group input-group-lg mb-3 mb-lg-0">
<div class="input-group-prepend">
<span class="input-group-text"><i class="far fa-calendar-alt"></i></span>
</div>
{{ form_widget(form.date, {'attr': {'class': 'form-control datepicker', 'placeholder': 'Date', 'data-date-format':'dd/mm/yyyy'}}) }}
<!--<input class="form-control datepicker" placeholder="Select date" type="text" required>-->
</div>
</div>
<div class="col-12 col-lg-3">
{{ form_widget(form.search, {'attr': {'class': 'btn btn-lg btn-primary btn-block mt-3 mt-md-0 animate-up-2' }} ) }}
<!--<button class="btn btn-lg btn-primary btn-block mt-3 mt-md-0 animate-up-2" type="submit">Find a desk</button>-->
</div>
{{form_end(form)}}
</div>
</div>
</div>
<script>
var placeSearch, autocompleteinput;
var input = document.getElementById('festival_search_location');
var componentForm = {
street_number: 'short_name',
route: 'long_name',
locality: 'long_name',
administrative_area_level_1: 'short_name',
country: 'long_name',
postal_code: 'short_name'
};
function initAutocomplete() {
google.maps.event.addDomListener(input, 'blur', function() {
if (jQuery('.pac-item:hover').length === 0) {
google.maps.event.trigger(this, 'focus', {});
google.maps.event.trigger(this, 'keydown', {
keyCode: 13
});
}
})
// Create the autocomplete object, restricting the search to geographical
// location types.
autocompleteinput = new google.maps.places.Autocomplete(
/** @type {!HTMLInputElement} */
(input), {
types: ['geocode']
});
// When the user selects an address from the dropdown, populate the address
// fields in the form.
autocompleteinput.addListener('place_changed', fillInAddress);
}
function fillInAddress() {
// Get the place details from the autocomplete object.
var place = autocompleteinput.getPlace();
if (place != null && place.place_id) {
//fill the hidden data
document.getElementById('festival_search_locationhidden').setAttribute('value', document.getElementById('festival_search_location').value)
document.getElementById('festival_search_placeid').setAttribute('value', place.place_id)
}
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyArRqV6iNkruffZtVT2G0iX4kfemd1SQD4&libraries=places&callback=initAutocomplete&sessiontoken={{uuid}}" async defer></script>