【问题标题】:How to create dependency dripdown in octobercms如何在 octobercms 中创建依赖关系滴灌
【发布时间】:2019-03-20 09:54:27
【问题描述】:

我的模型是“术语”和“位置”。期限取决于位置。每个位置有 4 个任期不同的 start_dates 和 finish_dates。

谁能帮我解决这个问题?

【问题讨论】:

标签: octobercms octobercms-plugins octobercms-backend


【解决方案1】:

在字段定义中:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-02
    • 1970-01-01
    • 2019-03-12
    • 2011-02-09
    • 2011-12-31
    • 2020-01-15
    相关资源
    最近更新 更多