[英]How Can I Display Value in Dropdown?
I want to display a value in a drop-down whenever I edit content, but I don't know how can I show it. 每当我编辑内容时,我都希望在下拉列表中显示一个值,但是我不知道如何显示它。 Can someone help me with this?
有人可以帮我弄这个吗?
Dropdown 落下
Here I have a dropdown that has the value of the country when I insert it to the database. 在这里,有一个下拉列表,其中包含将国家/地区插入数据库中时的国家/地区值。 But when I edit the drop-down, the country saved will be removed.
但是,当我编辑下拉菜单时,保存的国家/地区将被删除。
{{ Form::select('from_location', trans('countries'), null, ['class' => 'form-control', 'placeholder' => 'Select where you From']) }}
Update Controller 更新控制器
$aircraftFlights = Aircraft::find($id);
$aircraftFlights ->destination= $request->input('destination');
$aircraftFlights ->save();
You are passing null into field for current value. 您正在将null传递给当前值的字段。
Try this: 尝试这个:
{{Form::select('from_location', trans('countries'), !empty($aircraftFlights) ? $aircraftFlights->destination : null ,['class' => 'form-control', 'placeholder' => 'Select where you From'])}}<br>
You can refer here for more details: 您可以在此处参考以获取更多详细信息:
https://laravelcollective.com/docs/5.4/html#drop-down-lists https://laravelcollective.com/docs/5.4/html#drop-down-lists
Hope this helps 希望这可以帮助
{{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.