【发布时间】:2018-08-05 01:35:25
【问题描述】:
我让一个用户提交了一个表单,其中一些字段是这样的下拉列表
<div class="form-group row">
<label for="type" class="col-md-3 col-form-label text-md-right">Type</label>
<div class="col-md-9">
<select class ="form-control" id="type" name="type">
<option>Apartment</option>
<option>House</option>
<option>Studio</option>
<option>Flat</option>
</select>
@if ($errors->has('type'))
<span class="invalid-feedback">
<strong>{{ $errors->first('type') }}</strong>
</span>
@endif
</div>
</div>
效果很好。
我不想让用户编辑特定的表单。我可以通过为输入分配一个值并像这样调用数据来获取标题和照片等其他部分
<input id="Address" type="text" class="form-control" name="address" value="{{$Advert->address }}" required autofocus>
但是当我尝试在选择选项上做类似的事情时,什么也没有出现。这是编辑页面上的下拉菜单。
<div class="form-group row">
<label for="type" class="col-md-3 col-form-label text-md-right">Type</label>
<div class="col-md-9">
<select class ="form-control" id="type" name="type" value="{{$Advert->type}}">
<option></option>
<option>Apartment</option>
<option>House</option>
<option>Studio</option>
<option>Flat</option>
</select>
@if ($errors->has('type'))
<span class="invalid-feedback">
<strong>{{ $errors->first('type') }}</strong>
</span>
@endif
</div>
</div>
【问题讨论】:
标签: laravel laravel-5 drop-down-menu blade