laravel html中的选择选项更改为带有for循环的laravel集体形式
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46618108/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 16:45:52 来源:igfitidea点击:
select option in html change to laravel collective form with for loop
提问by user8663822
how can i change my html form to laravel collective form
如何将我的 html 表单更改为 laravel 集体表单
<select style="width:50%;margin-top: 10px;" name="idw">
<option value="0" disabled="true" selected="true">choose</option>
@foreach($warehouse as $w)
<option value="{{$w->id}}" name="idw" id="idw">{{$w->name}}</option>
@endforeach
</select>
in my collective form
以我的集体形式
{!! Form::select('type',
['Task' => $w->id =>w-> $name ],
null,
['class' => 'form-control chosen-type', 'placeholder' => 'Please Choose']
)!!}
i nvu use collective form before
i nvu 以前使用集体形式
回答by kerrin
In your form:
在您的表格中:
<div class="form-group">
{{ Form::label('Warehouses') }}
{{ Form::select('warehouse', $warehouseList, null, array('class'=>'form-control', 'placeholder'=>'Please select ...')) }}
</div>
In your controller:
在您的控制器中:
$warehouseList = Warehouse::all()->sortBy('name', SORT_NATURAL | SORT_FLAG_CASE)->pluck('name', 'id');