【发布时间】: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