【问题标题】:Slack Bolt Python: how to make the input field in modal optional?Slack Bolt Python:如何使模式中的输入字段可选?
【发布时间】:2021-08-27 08:06:35
【问题描述】:

我正在使用模态来收集数据。我通过以下代码打开了一个视图:

view = {
    "type": "modal",
    "title": {
        "type": "plain_text",
        "text": "My App",
        "emoji": True
    },
    "submit": {
        "type": "plain_text",
        "text": "Submit",
        "emoji": True
    },
    "close": {
        "type": "plain_text",
        "text": "Cancel",
        "emoji": True
    },
    "blocks": [
        {
            "type": "input",
            "element": {
                "type": "plain_text_input",
                "action_id": "plain_text_input-action"
            },
            "label": {
                "type": "plain_text",
                "text": "Please leave feedback here",
                "emoji": True
            }
        }
    ]
    }
slack_client.views_open(trigger_id=body['trigger_id'],view=view)

我想让输入文本可选,也就是说,即使用户将输入字段留空,他/她仍然可以提交模式。这能实现吗?

【问题讨论】:

    标签: slack slack-api slack-block-kit


    【解决方案1】:

    您可以添加"optional": true 作为输入块的属性。

    "blocks": [
            {
                "type": "input",
    
                "optional": true,
    
                "element": {
                    "type": "plain_text_input",
                    "action_id": "plain_text_input-action"
                },
                "label": {
                    "type": "plain_text",
                    "text": "Label",
                    "emoji": true
                }
            }
        ]
    

    【讨论】:

      猜你喜欢
      • 2019-06-14
      • 2021-12-18
      • 1970-01-01
      • 2020-03-14
      • 1970-01-01
      • 2022-10-19
      • 1970-01-01
      • 1970-01-01
      • 2012-12-06
      相关资源
      最近更新 更多