Skip to content

Commit

Permalink
Update views docs (#1130)
Browse files Browse the repository at this point in the history
  • Loading branch information
srajiang authored Sep 24, 2021
1 parent fd5d289 commit 2f3f499
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions docs/_basic/listening_modals.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,28 @@ order: 12
---

<div class="section-content">
If a <a href="https://api.slack.com/reference/block-kit/views">view payload</a> contains any input blocks, you must listen to <code>view_submission</code> requests to receive their values. To listen to <code>view_submission</code> requests, you can use the built-in <code>view()</code> method.
If a <a href="https://api.slack.com/reference/block-kit/views">view payload</a> contains any input blocks, you must listen to `view_submission` requests to receive their values. To listen to `view_submission` requests, you can use the built-in `view()` method.

<code>view()</code> requires a <code>callback_id</code> of type <code>string</code> or <code>RegExp</code>.
`view()` requires a `callback_id` of type `string` or `RegExp`.

You can access the value of the <code>input</code> blocks by accessing the <code>state</code> object. <code>state</code> contains a <code>values</code> object that uses the <code>block_id</code> and unique <code>action_id</code> to store the input values.
You can access the value of the input blocks by accessing the `state` object. `state` contains a values object that uses the `block_id` and unique `action_id` to store the input values.

---

##### Update views on submission

To update a view in response to a `view_submission` event, you may pass a `response_action` of type `update` with a newly composed `view` to display in your acknowledgement.

```javascript
// Update the view on submission
app.view('modal-callback-id', async ({ ack, body }) => {
await ack({
response_action: 'update',
view: buildNewModalView(body),
});
});
```
Similarly, there are options for [displaying errors](https://api.slack.com/surfaces/modals/using#displaying_errors) in response to view submissions.

Read more about view submissions in our <a href="https://api.slack.com/surfaces/modals/using#interactions">API documentation</a>.
</div>
Expand Down

0 comments on commit 2f3f499

Please sign in to comment.