Gmail 附加组件使用文本输入创建单选组

Gmail Add-on Create Radio Group with Text Input

我正在开发一个带有动态创建的无线电组的 Gmail 插件,例如:

如何插入输入文本框作为单选选项之一?

这是我目前拥有的:

var urlGroup = CardService.newSelectionInput()
      .setType(CardService.SelectionInputType.RADIO_BUTTON)
      .setTitle("Please select a link")
      .setFieldName("radio_group")


      //How do I get a text input field here as one of the radio options
      // This is the line I cannot figure out
      urlGroup.addItem(** insert input textbox here **)

      for (var g = 0; (g < getURLsection.length); g++) {
        //shorten long links to fit in card
        if (getURLsection[g].length > 21) {
          var URLname =  getURLsection[g].slice(0, 22) + "..." + getURLsection[g].slice(-5);
        } else {
          var URLname =  getURLsection[g]
          }

        urlGroup.addItem(URLname, getURLsection[g], false)
      }

      // create radio button group
      var section = CardService.newCardSection()
      .addWidget(urlGroup)

关于如何做到这一点有什么想法吗?
最好我想删除单词 Other: 并将其作为教科书中的 .setTitle("enter link here") 。

要在 Google 的附加组件中生成文本输入元素,您需要创建一个 TextInput 小部件对象,稍后您需要将其添加到给定的部分。

addItem 方法的文档中所述,它接收 textvalue 参数作为字符串,因此您不能在那里使用 TextInput 对象。

作为您想要实现的解决方法,您可以使用 'otherLink' 值创建一个无线电组选项:

  urlGroup.addItem('Enter link below:', 'otherLink', false);

以及您插入单选按钮组部分的文本输入小部件:

   var textInput = CardService.newTextInput()
    .setFieldName("text_input_form_input_key")
    .setTitle("enter link here")

  // create radio button group section with text input
  var section = CardService.newCardSection()
  .addWidget(urlGroup)
  .addWidget(textInput)

这样,文本输入将出现在单选按钮下方,如果从单选按钮组中选择的值为 [=26],您可以使用输入文本中输入的值 (link) =].