0

The checkbox does not take the value from the database. Help please. Thank you.

edit.blade.php

<div class="form-group">
  <input type="checkbox" class="" id="onloan" 
         value="{{ $item->onloan }}">
  <label for="onloan">On Loan</label>
</div>
3
  • 1
    You need to use checked property of input element. <input type="checkbox" class="" id="onloan" value="1" {{ $item->onloan == 1 ? 'checked' : '' }}> Commented Sep 24, 2020 at 3:14
  • Thanks! It worked, but really sorry I cannot Vote Up yet. Maybe you can write it in the answer and I'll select it as the answer? Commented Sep 24, 2020 at 4:30
  • @GhanuBha give your comment as an answer, so that it can be acceptable Commented Sep 24, 2020 at 6:41

2 Answers 2

2

You have to use checked property to check of input checkbox element.

<input type="checkbox" class="" id="onloan" value="1" {{ $item->onloan == 1 ? 'checked' : '' }}>
Sign up to request clarification or add additional context in comments.

Comments

0
<div class="form-group">
    <input type="checkbox" class="" id="onloan" value="{{ $item->onloan }}" {{$item->onloan == 1 ? 'checked' : ''}}>
    <label for="onloan">On Loan</label>
</div>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.