我坚持这个问题,我找不到如何解决一段时间后寻找一个例子。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