I have database like this:
column cek for define checkbox with code like this:
<input type="checkbox" value="{{ ($d->kd == $d->cek ? '0' : '1') }}" name="ada[]" @if($d->cek) checked @endif>
When its checked it will gave value '1', and when its unchecked its supposed to give value '0' but instead '0' i got null. Anyone here how should it? Thank you.
CodePudding user response:
Try this
<input type="checkbox" value="{{ ($d->kd == $d->cek ? '0' : '1') }}" name="ada[]" @if($d->kd == '1' ? 'checked' : '')@endif>
CodePudding user response:
<input type="checkbox" value="{{ ($d->kd == $d->cek ? '0' : '1') }}"
name="ada[]" @if($d->kd == '1') checked @endif >