问题
Functions for select field choices cannot be read when inside an Array field
I can call a function to populate a select field's choices but when the same select field is inside an Array field I get 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;
}
}
}
The first select works (name: 'test_dynamic_select') The second one does not. (name: 'test_dynamic_select_in_array')
回答1:
This was fixed in Apostrophe 2.92.1. You should run "npm update" and the problem should then be resolved.
来源:https://stackoverflow.com/questions/56581537/dynamic-select-fields-in-apostrophe-inside-array-field-type