0
我在Laravel中創建了一個編輯表單,並且我想選擇Select Dropdown中的選定(數據庫)值。我現在正在做如下。正確的方法或更好的方法是可能的嗎?我正在使用Laravel 5.4。Laravel編輯表單 - 選擇默認選項
<select class="form-control" id="type" name="type">
<option value="admin" @if($user->type==='admin') selected='selected' @endif>Admin</option>
<option value="telco" @if($user->type==='telco') selected='selected' @endif>Telco</option>
<option value="operator" @if($user->type==='operator') selected='selected' @endif>Operator</option>
<option value="subscriber" @if($user->type==='subscriber') selected='selected' @endif>Subscriber</option>
</select>
這是有道理的! – Mohammad