【问题标题】:Dynamic Select fields in apostrophe inside Array field type数组字段类型中撇号中的动态选择字段
【发布时间】: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


【解决方案1】:

这已在 Apostrophe 2.92.1 中得到修复。您应该运行“npm update”,然后问题应该得到解决。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-04-15
    • 1970-01-01
    • 2011-08-25
    • 1970-01-01
    • 2016-08-21
    • 2019-02-15
    • 2021-06-01
    • 1970-01-01
    相关资源
    最近更新 更多