I've a form to be completed to create a post
. Now after creating that post, if I want to edit it, I'm showing a select
option in the edit page something like below. (I am using Laravel)
<select name="posts">
@foreach($posts as $post)
<option value="{{$post->id}}"> {{$post->name }} </option>
@endforeach
</select>
Now I need to preselect the populated select field with the current post name
. I have a post id in the URL which I can get know in which post I am in. How can I select the right option without making a duplicate of the same in the options field. ?