我堅持這個問題,我找不到如何解決一段時間後尋找一個例子。OCTOBERCMS下拉選項取決於其他下拉選定的值
兩個下拉選項依賴於它們的值。
我有「區域」值而確定一臺(套與簡單的樹行工作)與fields.yaml文件的結構如下:
fields:
id:
label: Número
oc.commentPosition: ''
span: auto
disabled: 1
type: number
area_id:
label: 'Parente de'
oc.commentPosition: ''
emptyOption: 'Sem valor'
span: auto
type: dropdown
area:
label: Área
oc.commentPosition: ''
span: full
required: 1
type: text
我也有另一個表「modulos」的價值觀在fields.yaml結構如下:
fields:
modulo:
label: Módulo
oc.commentPosition: ''
span: auto
required: 1
type: text
area:
label: Área
oc.commentPosition: ''
nameFrom: area
emptyOption: 'Sem valor'
span: auto
descriptionFrom: id
type: relation
在 '區域' 的模式,我有:
...
public $hasMany = [
'modulos' => ['JML\Gkb\Models\Modulos']
];
在「Modulos」模式,我有
....
public $belongsTo = [
'area' => ['\JML\Gkb\Models\Area']
];
我有與先前場和兩個下拉領域沒有任何過濾好的工作關係的其他模式,以及troubleshoting場(modulos),在那裏我找不到根據「區域」下拉列表的值過濾的方法我在fields.yaml中有以下內容。
....
modulo_id:
label: mod
oc.commentPosition: ''
emptyOption: 'Sem valor'
span: auto
required: 1
dependsOn:
area
type: dropdown
tab: Geral
在我的模型PHP文件,我已經定義了下拉菜單,我有:
public function getModuloIdOptions() {
return Modulos::where('area_id', '=', $this->area)->lists('modulo', 'id');
}
這對我來說似乎是合乎邏輯(也許不是),我用DB嘗試也和許多其他。我試着用dd()
來看看我能否從第一個下拉列表中獲得值無濟於事。如果我嘗試過濾這些值,則根本不顯示任何值(空值除外)。
有幫助嗎?
TIA
JL
Ty爲編輯,它更清楚與他們......不幸的是,這是我的戰鬥正確地發佈代碼:(。 – JLongo