【发布时间】:2019-08-15 07:06:03
【问题描述】:
在数组字段中时无法读取选择字段选项的函数
我可以调用一个函数来填充选择字段的选项,但是当相同的选择字段在数组字段中时,我得到 TypeError: Cannot read property 'functionname' of undefined/
module.exports = {
name: 'testtype',
addFields: [
{
name: 'test_dynamic_select',
type: 'select',
choices: 'testchoice'
},
{
name: 'insidearray',
label: 'In Array',
type: 'array',
schema: [
{
name: 'test_dynamic_select_in_array',
type: 'select',
choices: 'testchoice'
},
]
}
],
construct: function(self, options) {
self.testchoice = async function(req) {
var testarray = [
{
label: 'London',
value: 'london'
},
{
label: 'Edinburgh',
value: 'edinburgh'
},
{
label: 'Manchester',
value: 'manchester'
}
];
return testarray;
}
}
}
第一个选择有效(名称:'test_dynamic_select') 第二个没有。 (名称:'test_dynamic_select_in_array')
【问题讨论】:
-
听起来像是我们需要修复的错误。最有可能的数组字段没有将模块属性传播到它们的子字段。
标签: apostrophe-cms