复选框无法使用laravel背包CRUD

问题描述 投票:0回答:1
$this->crud->addField([
        'name' => 'status',
        'label' => 'Featured item',
        'type' => 'checkbox',
    ]);

生成的代码如下:

<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>

使用上面的代码作为复选框,一切正常,值正确保存在数据库中并正确提取。但是未选中复选框。

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

laravel laravel-5 backpack-for-laravel
1个回答
1
投票

对我来说,我的问题是在迁移更改了我的某些列之后,我的模型类中的$fillable数组没有更新。

我记得要向XyzCrudController添加新字段,而不要向$fillable数组添加新字段。

© www.soinside.com 2019 - 2024. All rights reserved.