如何使用Laravel背包创建依赖选择?

时间:2018-08-28 17:49:13

标签: backpack-for-laravel

如何使用 larpack backpack 创建依赖选择,例如国家/城市关系? 就像:只显示所选国家/地区的城市

    $this->crud->addField([  // Select2
        'label' => "country",
        'type' => 'select2',
        'name' => 'country_id', // the db column for the foreign key
        'entity' => 'country', // the method that defines the relationship in your Model
        'attribute' => 'country', // foreign key attribute that is shown to user
        'model' => "App\Models\Country" // foreign key model
     ]);

    $this->crud->addField([  // Select2
        'label' => "City",
        'type' => 'select2',
        'name' => 'city_id', // the db column for the foreign key
        'entity' => 'city', // the method that defines the relationship in your Model
        'attribute' => 'city', // foreign key attribute that is shown to user
        'model' => "App\Models\City" // foreign key model
     ]);

1 个答案:

答案 0 :(得分:1)

有一个功能,但尚未合并。您可以查看[Feature][3.4][Ready] Select2_from_ajax can depend on any other input并查看修改后的文件,然后在您的安装中复制它。