我被这个问题困住了,经过一段时间搜索示例后,我无法弄清楚如何解决。
这两个下拉选项是取决于它们的值的表格。
我有一个带有“区域”值的表(嵌套在简单的树上可以正常工作),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
我在 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']
];
在我的“模数”模型中
....
public $belongsTo = [
'area' => ['\JML\Gkb\Models\Area']
];
我有其他模型与以前的字段有关系,两个下拉字段在没有任何过滤器的情况下工作正常,在故障排除字段(模数)中我找不到基于“区域”下拉列表的值进行过滤的方法我有以下在 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
杰伦