Issue
How to show old data of select
element in Laravel?
Data can be shown in input
like this:
<input id="name" name="name" class="form-control" type="text" value="{{ old('name', $user->name) }}">
when the element is select
,how to show the old data?
<select class="form-control" name="gender">
<option value="male">male</option>
<option value="female">female</option>
</select>
Solution
<select class="form-control" name="gender">
<option value="male" @if (old('gender') == 'male') selected="selected" @endif>male</option>
<option value="female" @if (old('gender') == 'female') selected="selected" @endif>female</option>
</select>
Answered By - HTMHell
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.