slack - Slack Bolt Python:如何使模式中的输入字段可选?
问题描述
我正在使用模态来收集数据。我通过以下代码打开了一个视图:
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)
我想让输入文本可选,也就是说,即使用户将输入字段留空,他/她仍然可以提交模式。这可以实现吗?
解决方案
您可以添加"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
}
}
]
推荐阅读
- javascript - 如何在 socket.io 中查看房间内的用户数量?
- apache-flink - MapState 在 RichCoFlatMapFunction 中始终为空
- codenameone - 代号一中如何使用坐标布局?
- ios - PWA 与 Safari 网站有什么区别?
- c++ - 使用 cmake 在 Linux for Windows 上交叉编译程序
- php - PhpStorm:更改 DocumentRoot 后更改 URL
- vba - 如何使用 VBA 在 ms 访问表单中创建自定义自动编号?
- javascript - JavaScript:从对象数组中删除空/未定义/空属性
- php - 当两个不同的路由组内有相同的路由时,如何管理 Blade 中的路由?
- python - 提取量的正则表达式