i use laravel 4.2, in my project, i use option bottomn and checkbox, data stored in database :
- id = 1 | title = base1
- id = 2 | title = base2
now, how can i in this code, checked option btn with data stored :
<div class="col-md-4">
<div class="radio-list">
@foreach($base as $ba)
<label for="base-label-{{$ba->id}}">
<div class="radio" id="label-{{$ba->id}}"><input type="radio" name="base" id="base-label-{{$ba->id}}" value="{{$ba->id}}" {{ !empty($ba->id) ? 'checked' : '' }}></div> {{$ba->title}}
</label>
@endforeach
</div>
</div>
Consider you have the retrieved
id
data from database as$ba_id
, you could compare it lik this :