0
$this->crud->addField([
        'name' => 'status',
        'label' => 'Featured item',
        'type' => 'checkbox',
    ]);

The generated code is following:

<div class="form-group col-md-12">
  <div class="checkbox">
    <label>
      <input type="hidden" value="0" name="status">
      <input type="checkbox" name="status" value="1"> Featured item
    </label>
  </div>
</div>

Using the above code for checkbox, Everything works fine, value is saving correctly in database and fetched correctly. But checkbox is not checked.

The checkbox is not checked even if the value is 1.

Sarvesh Acharya
  • 176
  • 1
  • 4
  • 14
  • Hi there! What version of Backpack\CRUD are you using? Does a ```composer update``` fix it for you? I just checked the current checkbox.blade.php file and it seems to have been fixed in the meantime. Cheers! – tabacitu Mar 06 '17 at 13:26
  • Hi Its 3.2 for Backpack\CRUD and laravel 5.4. No composer update didn't solve it. – Sarvesh Acharya Mar 06 '17 at 17:17
  • Try to remove your backpack folder from the vendor and do the `composer update` again – João Mantovani Mar 10 '17 at 11:38
  • 1
    For me, my problem was that my `$fillable` array in my model class wasn't updated after a migration had changed some of my columns. I'd remembered to add new fields to the XyzCrudController but not to the `$fillable` array. – Ryan May 19 '17 at 19:39
  • @Ryan could you make your comment as an answer ? That was my problem (The simplest things ...) and I want to mark is a a correct answer. – Marc Brillault Dec 29 '19 at 12:42
  • 1
    @MarcBrillault Glad to hear that it helped. I wrote an answer here that you can upvote (but won't be able to accept since you weren't the original question asker): https://stackoverflow.com/a/59525658/470749 – Ryan Dec 30 '19 at 04:17

1 Answers1

1

For me, my problem was that my $fillable array in my model class wasn't updated after a migration had changed some of my columns.

I'd remembered to add new fields to the XyzCrudController but not to the $fillable array.

Ryan
  • 22,332
  • 31
  • 176
  • 357