1
如何在laravel 5.3的刀片中使用optgroup與陣列?我在項目中使用select2。如何在laravel的刀片中使用optgroup與陣列
例如:
<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()沒有給你預期的輸出嗎? –