@include('components.form.select', ['name' => $name.'_id', 'id_name' => $name.'_id', 'class' => 'form-control', 'list' => (isset($list)) ? $list : null, 'value' => (isset($value)) ? $value : null, 'style' => 'width: 100%;'])

<input type="hidden" name="{{ $name }}" id="{{ $name }}" @if (isset($value) && isset($list) && $value) value="{{ $list[$value] }}"@endif>

@include('boilerplate::load.select2')

@push('js')
<script>
	$(function() {
		$('#{{ $name }}_id').select2({
			placeholder: "Sélectionnez une Ville",
			delay: 250,
			ajax: {
				url: "{{ route('Villes.autocomplete') }}",
				dataType: 'json',
				data: function (params) {
					var query = {
						search: params.term,
					}
					// Query parameters will be ?search=[term]
					return query;
				}
			}
		});

		$("#{{ $name }}_id").on("select2:select", function (e) { 
			var select_val = $(e.currentTarget).text();
			var ville_sel = select_val.trim();
			ville_sel = ville_sel.replace(/\(.*\)/g, "");
			ville_sel = ville_sel.trim();
			$('#{{ $name }}').val(ville_sel);
		});

	});
</script>
@endpush
