0

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

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)

在此处输入图像描述

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

4

1 回答 1

3

您可以添加"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
            }
        }
    ]
于 2021-08-27T10:57:22.220 回答