Alexey Buistov
Alexey Buistov

Reputation: 209

Is it possible to make Slack static_select a mandatory field in a modal?

When using static_select with no option selected by default, is it possible to make the selection of some option mandatory? So that user can't submit the modal without making a selection..

Thanks in advance!

Upvotes: 0

Views: 1819

Answers (3)

Yuki
Yuki

Reputation: 740

simply use the field initial_option, from Slack docs: https://api.slack.com/reference/block-kit/block-elements#select

Upvotes: 0

Ankit Shubham
Ankit Shubham

Reputation: 3619

I got it to work with the following code:

{
  "block_id": "status",
  "type": "input",
  "label": {
    "type": "plain_text",
    "text": "Status"
  },
  "element": {
    "action_id": "status",
    "type": "static_select",
    "placeholder": {
      "type": "plain_text",
      "text": `Select status`,
      "emoji": true
    },
    "options": [
      {
        "text": {
          "type": "plain_text",
          "text":  "OPEN",
          "emoji": true
        },
        "value": ".OPEN"
      },
      {
        "text": {
          "type": "plain_text",
          "text":  "IN_PROGRESS",
          "emoji": true
        },
        "value": ".IN_PROGRESS"
      },
      {
        "text": {
          "type": "plain_text",
          "text":  "COMPLETED",
          "emoji": true
        },
        "value": ".COMPLETED"
      }
    ]
  },
},

Upvotes: 0

Adheesh
Adheesh

Reputation: 13

Have you created the static_select under a block of 'type' : 'input'? This is what worked for me. I ran across the same issue as you when I had the block as 'type': 'section'.

Upvotes: 1

Related Questions