Dynamic Select fields in apostrophe inside Array field type

為{幸葍}努か 提交于 2019-12-11 06:47:45

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!