【发布时间】:2019-03-20 09:54:27
【问题描述】:
我的模型是“术语”和“位置”。期限取决于位置。每个位置有 4 个任期不同的 start_dates 和 finish_dates。
谁能帮我解决这个问题?
【问题讨论】:
标签: octobercms octobercms-plugins octobercms-backend
我的模型是“术语”和“位置”。期限取决于位置。每个位置有 4 个任期不同的 start_dates 和 finish_dates。
谁能帮我解决这个问题?
【问题讨论】:
标签: octobercms octobercms-plugins octobercms-backend
在字段定义中:
location_id:
label: Location
type: dropdown
term_id:
label: Term
type: dropdown
dependsOn: location
然后,在控制器中:
public function getLocationOptions()
{
// this will return an array of Location names indexed by id
return Location::pluck('name', 'id);
}
public function getTermOptions()
{
return Term::where('location_id', $this->location_id)->pluck('name', 'id');
}
欲了解更多信息:OctoberCMS Documentation
【讨论】: