phpslackslack-api

Is it possible to make an input not required with Slack API?


I'm building a Slack App feature with a modal and several inputs.

One of them is a static select with some options.

I would like to make it optionnal but it seems that there is no solution for that.

I tried to set dispatch_action to false but it is unrelated I believe.

Here is my input configuration :

[
    'type' => 'input',
    'dispatch_action' => false,
    'label' => [
    'type' => 'plain_text',
        'text' => 'Choose an option (or not)',
    ],
    'element' => [
        'type' => 'static_select',
        'placeholder' => [
            'type' => 'plain_text',
            'text' => 'Choose an option',
        ],
        'options' => array_map(static function($data) {
            return [
                'text' => [
                    'type' => 'plain_text',
                    'text' => $data->name,
                ],
                'value' => (string) $data->id,
            ];
        }, $dataValues),
    ],
],

I can't make this field not required

Thanks for your help !


Solution


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

    'type' => 'input',
    'optional': true,
    'dispatch_action' => false,