I need to give selected value like this html:
<?php
$items = DB::table('course')->get()->pluck('name','id');
$selectID = 3;
?>
<div class="form-group">
{{ Form::label('course_title', 'Course Title') }}
{!! Form::select('myselect', $items, $select, ['class' => 'form-control']) !!}
</div>
This show similar types of following options :
<select name="myselect" id="myselect">
<option value="1">Computer Introduction</option>
<option value="2">Machine Learning</option>
<option value="3" selected='selected'>Python Programming</option>
<option value="4">Networking Fundamentals</option>
.
.
.
.
</select>
You can do it like this.
<select class="form-control" name="resoureceName">
<option>Select Item</option>
@foreach ($items as $item)
<option value="{{ $item->id }}" {{ ( $item->id == $existingRecordId) ? 'selected' : '' }}> {{ $item->name }} </option>
@endforeach </select>
use this package and check the docs:
https://laravelcollective.com/docs/5.2/html#drop-down-lists
form you html , you need use this mark
{!! Form::select('size', array('L' => 'Large', 'S' => 'Small'), 'S'); !!}
If anyone is still here, here is my simple version.
<select name="status" class="js-example-basic-single w-100">
<option value="" @if($brand->status == '') ? selected : null @endif disabled>Choose what to be seen on brand section</option>
<option value="TA" @if($brand->status == 'TA') ? selected : null @endif>Title Active</option>
<option value="ITA" @if($brand->status == 'ITA') ? selected : null @endif>Image Title Active</option>
</select>
@foreach ($categories as $category)
<option value="{{$category->id}}"
@foreach ($posts->postRelateToCategory as $Postcategory)
@if ($Postcategory->id == $category->id)
{{'selected="selected"'}}
@endif
@endforeach >
{{ $category->category_name }} </option>
@endforeach
Try this
<select class="form-control" name="country_code" value="{{ old('country_code') }}">
@foreach (\App\SystemCountry::orderBy('country')->get() as $country)
<option value="{{ $country->country_code }}"
@if ($country->country_code == "LKA")
{{'selected="selected"'}}
@endif
>
{{ $country->country }}
</option>
@endforeach
</select>