lundi 28 août 2017

Laravel Edit Form - Select default selection

I'm creating an edit form in Laravel and I would like to select the selected (database) value in Select Dropdown. I'm doing it now as below. Is the right method or anything better is possible? I'm using Laravel 5.4.

<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>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire