[英]How Can I Display Value in Dropdown?
每當我編輯內容時,我都希望在下拉列表中顯示一個值,但是我不知道如何顯示它。 有人可以幫我弄這個嗎?
落下
在這里,有一個下拉列表,其中包含將國家/地區插入數據庫中時的國家/地區值。 但是,當我編輯下拉菜單時,保存的國家/地區將被刪除。
{{ Form::select('from_location', trans('countries'), null, ['class' => 'form-control', 'placeholder' => 'Select where you From']) }}
更新控制器
$aircraftFlights = Aircraft::find($id);
$aircraftFlights ->destination= $request->input('destination');
$aircraftFlights ->save();
您正在將null傳遞給當前值的字段。
嘗試這個:
{{Form::select('from_location', trans('countries'), !empty($aircraftFlights) ? $aircraftFlights->destination : null ,['class' => 'form-control', 'placeholder' => 'Select where you From'])}}<br>
您可以在此處參考以獲取更多詳細信息:
https://laravelcollective.com/docs/5.4/html#drop-down-lists
希望這可以幫助
{{Form::select('from_location', trans('countries'),null,['class' => 'form-control', 'placeholder' => 'Select where you From', 'value' => $your_value_here])}}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.