Try to include the value in this format:
{!!Form::select('itemid',$itemid,Input::old('itemid'),array('class'=>'col-md-4', 'placeholder' => 'Search for an Item'))!!}
just give the fetched value instead of Input::old('itemid')
I have a select box that is populated by an ajax call to a get method, I would like to change the select box to an Input and autocomplete textbox.
Ajax Call
$(document).ready(function () {
$(".js-search-items").select2({
placeholder: 'Find an Item',
allowClear: true,
ajax: {
type: 'POST',
url: '{{ action('\Modules\Admin\Http\Controllers\Restaurant\Menus\ItemsController@postGetItems') }}',
dataType: 'json',
delay: 250,
data: function (params) {
return {
q: params.term,
page: params.page
};
},
processResults: function (data, params) {
items = [];
$.each($.parseJSON(data), function () {
items.push({
id: this.ItemID,
text: this.ItemName
});
});
return {
results: items,
pagination: {
more: (params.page * 30) < items.length
}
};
},
cache: true
},
minimumInputLength: 3
});
});
current select box
<div class="form-group">
{!! Form::label('itemID', 'Name', array('class' => 'col-md-2 control-label')) !!}
<select name="itemID" class="noSelect2 js-search-items col-md-4"></select>
</div>
can i change the select2 to autocomplete and salvage the script function to grab my data?
I want to do something like
{!! Form::text('itemID', null, ['class' => 'col-md-4', 'placeholder' => 'Search for an Item']) !!}
instead of the select input
Please or to participate in this conversation.