【发布时间】:2017-01-26 04:09:03
【问题描述】:
如何在 laravel 5.3 的刀片中使用 optgroup 和数组?
我在我的项目中使用select2。
例如:
<select class="form-control select2">
<optgroup label="Top Airport">
<option value="MHD">Mashhad</option>
<option value="THR">Tehran</option>
</optgroup>
<optgroup label="All Airport">
<option value="MHD">Mashhad</option>
<option value="THR">Tehran</option>
<option value="LON">London</option>
.
.
.
</optgroup>
</select>
在Controller:
public function index()
{
$airport = Airport::where('status', 1)->pluck('city', 'iata');
return view($this -> path_site_theme() . '.home.index', ['airport' => $airport]);
}
在index.blade.php:
{{ Form::select('from', ['Top Airport' => ['MHD', 'Mashhad', 'THR' => 'Tehran'], 'All Airport' => $airport], null, ['class' => 'form-control select2']) }}
【问题讨论】:
-
有什么问题? Form::select() 没有给你预期的输出吗?
标签: laravel laravel-5.3 laravel-blade