首页 文章

Laravel Backpack select2_multiple无法正确显示

提问于
浏览
2

我正在使用Backpack for Laravel,并实现了一个select2_multiple字段 . 该字段正常工作,但它根本无法正常显示 . 它被定义为:

$this->crud->addField([       // Select2Multiple = n-n relationship (with pivot table)
        'label' => "Categories",
        'type' => 'select2_multiple',
        'name' => 'categories', // the method that defines the relationship in your Model
        'entity' => 'categories', // the method that defines the relationship in your Model
        'attribute' => 'title', // foreign key attribute that is shown to user
        'model' => "App\Models\Category", // foreign key model
        'pivot' => true // on create&update, do you need to add/delete pivot table entries?
    ]);

存在数据透视表,模型上的关系也存在 . 该字段显示一秒钟,然后快速隐藏在页面加载(我想由一些JS) . 您可以在下面的“类别”标签中看到,只有空格:

enter image description here

但是,我可以点击白色空格然后它会出现并允许我按预期选择类别(虽然它显示得相当奇怪):

enter image description here

这是所有默认功能,我没有编辑select2_multiple模板或任何JS . 为什么这么糟糕?

2 回答

  • 0

    我相信这是一个错误has since been fixed . composer update 应该为你修复它 .

  • 0

    模型是否正确?也许应该是

    'model' => "App\Category", // foreign key model
    

相关问题