【问题标题】:how to create dependent select using backpack-for-laravel?如何使用背包换laravel创建依赖选择?
【发布时间】:2019-02-03 10:20:42
【问题描述】:

如何使用backpack-for-laravel创建依赖选择类似国家/城市的关系? 喜欢:只显示所选国家/地区的城市

    $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
     ]);

【问题讨论】:

  • 已经有一段时间了,但是您解决了这个问题吗?我也有同样的问题。今天发了。这是一个链接:stackoverflow.com/questions/62468799/…
  • 对于 4.1 的版本是否有任何解决方案?我也需要这样做。

标签: laravel-backpack


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2020-10-09
    • 2019-07-07
    • 2016-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-07
    相关资源
    最近更新 更多