【问题标题】:Zapier CLI : How do you clear the value of an input filed when dependent field changes?Zapier CLI:当依赖字段更改时,如何清除输入字段的值?
【发布时间】:2021-09-07 22:19:07
【问题描述】:

我正在使用 Zapier CLI 构建一个 Zapier 应用程序。

我创建了 2 个动态输入字段,均由 API 填充。

字段 2 (channelId) 取决于字段 1 (appId) 中的选择。

inputFields: [
 { 
    key: 'appId',
    label: 'App',
    required: true, 
    type: 'text', 
    helpText: 'Choose the App', 
    dynamic: 'app.id.display_name',
    altersDynamicFields:true,
  },
  {
    key: 'channelId',
    label: 'Channel',
    required: true,
    type: 'string',
    helpText: 'Choose the Channel',
    dynamic: 'channel.channel',
  }
]

这在用户第一次做出选择时效果很好。

但是,如果他们同时选择这两个选项,然后更改字段 1 (appId),则不会清除字段 2 (channelId) 中的选择

如果您重新打开菜单,您会看到新的选择 - 因此perform 函数正在资源中运行,但之前选择的值不会被清除 - 留下无效的选择。

当改变它的字段改变时,如何确保从属字段被清除?

【问题讨论】:

    标签: zapier zapier-cli


    【解决方案1】:

    好问题! altersDynamicFields 属性名称容易混淆。它与custom/dynamic fields 相关联,在其中动态地从表单中添加和删除字段。因为channelId 始终存在,所以appId 更改时不会重新计算。

    作为一种解决方案,您可以制作 channelId 自定义字段。它会一直存在,但是当appId 发生变化时,它会被正确地失效(我认为):

    inputFields: [
     { 
        key: 'appId',
        label: 'App',
        required: true, 
        type: 'text', 
        helpText: 'Choose the App', 
        dynamic: 'app.id.display_name',
        altersDynamicFields:true,
      },
      // functions are re-run when fields with `altersDynamicFields: true` are changed
      () => [{
        key: 'channelId',
        label: 'Channel',
        required: true,
        type: 'string',
        helpText: 'Choose the Channel',
        dynamic: 'channel.channel',
      }]
    ]
    

    【讨论】:

      猜你喜欢
      • 2018-10-27
      • 2015-10-18
      • 2020-03-20
      • 1970-01-01
      • 1970-01-01
      • 2019-07-10
      • 2016-02-01
      • 2020-01-11
      • 1970-01-01
      相关资源
      最近更新 更多