2

I'm using modal to collect data. I opened a view by the following code:

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)

enter image description here

I want to make the input text optional, that is, even though the user leaves the input field blank, he/she can still submit the modal. Can this be realized?

Rachel Dong
  • 179
  • 1
  • 3
  • 11

1 Answers1

5

You can add "optional": true as property of input block.

"blocks": [
        {
            "type": "input",

            "optional": true,

            "element": {
                "type": "plain_text_input",
                "action_id": "plain_text_input-action"
            },
            "label": {
                "type": "plain_text",
                "text": "Label",
                "emoji": true
            }
        }
    ]
Suyash Gaur
  • 2,481
  • 2
  • 9
  • 22