<select name="nation" class="custom-select" >
<option selected value="">Choose...</option>
<option value="{{@$teacher->nation}}" {{@$teacher->nation== "Pakistan" ? 'selected' : ''}} >{{@$teacher->nation}}</option>
</select>
问题:我的下拉列表为空。
答案 0 :(得分:1)
<select name="nation" class="custom-select">
<option selected value="">Choose...</option>
@foreach($teachers as $teacher)
<option value="{{ $teacher->nation }}" {{ $teacher->nation == "Pakistan" ? 'selected' : '' }} >{{ $teacher->nation }}</option>
@endforeach
</select>
答案 1 :(得分:0)
这是laravel中的下拉结构
<select class="form-control m-bot15" name="role_id">
@if($roles->count() > 0)
@foreach($roles as $role)
<option value="{{$role->id}}">{{$role->name}}</option>
@endForeach
@else
No Record Found
@endif
</select>
答案 2 :(得分:0)
<select name="nation" class="custom-select" >
<option value="">Choose...</option>
@foreach ($teachers as $key => $value)
<option value="{{ $key }}" {{ old('nation') == $key ? 'selected' : ''}}>{{ $value }}</option>
@endforeach
</select>