带有$variable的html下拉列表在显示中给出错误结果
我试图在html/引导程序中创建下拉列表,这导致我的输出设计错误。让我分享一下我在代码中所做的工作 控制器代码:带有$variable的html下拉列表在显示中给出错误结果,html,laravel,Html,Laravel,我试图在html/引导程序中创建下拉列表,这导致我的输出设计错误。让我分享一下我在代码中所做的工作 控制器代码: $countries = Country::select('country','id')->get(); HTML代码: 国家: @foreach($key=>$val的国家) {{$val} @endforeach 试试我的代码片段,因为循环中的$country包含来自country <div class="form-group">
$countries = Country::select('country','id')->get();
HTML代码:
国家:
@foreach($key=>$val的国家)
{{$val}
@endforeach
试试我的代码片段,因为循环中的$country
包含来自country
<div class="form-group">
Country:<select name="country_id" id="exchange" class="form-control" for="id">
<option value="" id="fid"></option>
@foreach($countries as $country )
<option value="{{ $country->id }}">{{ $country->country }}</option>
@endforeach
</select>
</div>
国家:
@foreach($国家作为$国家)
{{$country->country}
@endforeach
如下更改控制器代码
$countries = Country::pluck('country', 'id');
这是预期的工作。。。您能建议我如何制作
collective-laravel
表单吗?您所说的collective
是什么意思?也就是说,laravel:collective\Html\form
您使用的是哪个版本?