我正在使用 laravel 5.4 ,"已选择"选项标签的选项不起作用。
有什么建议吗?
例如:
<div class="labelandinput">
<label >Gender:</label>
<select name="gender" id="gender" >
@if ($info->gender=="male")
<option value="male" selected>Male</option>
<option value="female">Female</option>
@elseif($info->gender=="female")
<option value="male">Male</option>
<option value="female" selected>Female</option>
@endif
</select>
</div>
答案 0 :(得分:0)
你可以这样做:
{!! Form::select('gender', ['male' => 'Male', 'female' => 'Female'], 'male'); !!}
查看文档:{{3}}
<div class="labelandinput">
{{ Form::label('gender', 'Gender:') }}
@if ($info->gender == "male")
{!! Form::select('gender', ['male' => 'Male', 'female' => 'Female'], 'male'); !!}
@elseif ($info->gender == "female")
{!! Form::select('gender', ['male' => 'Male', 'female' => 'Female'], 'female'); !!}
@endif
</div>