Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/240.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在laravel blade中创建可搜索的选择选项表单_Php_Jquery_Laravel_Forms - Fatal编程技术网

Php 如何在laravel blade中创建可搜索的选择选项表单

Php 如何在laravel blade中创建可搜索的选择选项表单,php,jquery,laravel,forms,Php,Jquery,Laravel,Forms,我正在尝试构建一个带有可搜索选项的城市选择选项表单。到目前为止,我已经构建了这个,但是所选的数据没有被保存,我的代码仍然缺少搜索功能 {!! Form::select('custom_field1', array('Delhi', 'Goa'), '1', ['class' => 'form-control', 'placeholder' => 'Select City']); !!} 原始代码 {!!Form::label('custom_field1',$contact_cu

我正在尝试构建一个带有可搜索选项的城市选择选项表单。到目前为止,我已经构建了这个,但是所选的数据没有被保存,我的代码仍然缺少搜索功能

{!! Form::select('custom_field1', array('Delhi', 'Goa'), '1', ['class' => 'form-control', 'placeholder' => 'Select City']); !!}
原始代码


{!!Form::label('custom_field1',$contact_custom_field1.':')
{!!Form::text('custom_field1',null,['class'=>'表单控件','placeholder'=>$contact_custom_field1])
您可以使用
列表
属性和
来实现仅使用html的目的

<div class="col-md-3">
    <div class="form-group">
        <label for="custom_field1">{{ $contact_custom_field1 }}:</label>
        <input id="custom_field1" name="custom_field1" type="text" list="custom_field1_datalist" class="form-control" placeholder="{{ $contact_custom_field1 }}">
        <datalist id="custom_field1_datalist">
            <option>Delhi</option>
            <option>Goa</option>
        </datalist>
        <span id="error" class="text-danger"></span>
    </div>
</div>

另外,由于您已经使用JQuery标记对这个问题进行了标记,您可以使用类似的库,并让它为您这样做

您只需将其放入
标记中即可

<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
然后,在javascript中,将其添加到
$(document.ready(…)
块中

$(document).ready(function() {
    $('.select2').select2();
});

你太棒了,它成功了,我现在得了11分,我可以得到答案,很抱歉,我很高兴它成功了。别担心。我想你仍然可以接受答案。