复选框无法正常工作laravel背包CRUD [英] Checkbox not working laravel backpack CRUD

查看:63
本文介绍了复选框无法正常工作laravel背包CRUD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

推荐答案

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

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.

我记得要向XyzCrudController添加新字段,但不能向$fillable数组添加新字段.

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

这篇关于复选框无法正常工作laravel背包CRUD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆