0
votes
$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.

1
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
Hi Its 3.2 for Backpack\CRUD and laravel 5.4. No composer update didn't solve it. - Sarvesh Acharya
Try to remove your backpack folder from the vendor and do the composer update again - João Mantovani
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
@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): stackoverflow.com/a/59525658/470749 - Ryan

1 Answers

1
votes

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.