Pass variables as "secret" payload #8
-
Hello everyone!
But on step 3 I have just text - which I show to user. But this is not for work - just for show. How can I pass variables on step 2 to modal on step 3?
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
This is a good use case for the modal's Within the slack-php framework, there is a simple abstraction for this that is very much like what you've requested. To set (during step 2): $previewModal = Modal::new()
// ...
->tap(function (Modal $modal){
$modal->encodePrivateMetadata([
'var1' => 'value1',
'var2' => 'value2',
]);
// ...
}); To get (during step 3): $ctx->payload()->getMetadata()->get('var1'); Note: If you inspect the Another Note: There is a way to use
|
Beta Was this translation helpful? Give feedback.
-
@jlindblom-godaddy wow, that's it, thank you! I looking in documentation whole hours, but did't find this elem :( |
Beta Was this translation helpful? Give feedback.
This is a good use case for the modal's
private_metadata
field (see https://api.slack.com/reference/surfaces/views).Within the slack-php framework, there is a simple abstraction for this that is very much like what you've requested.
To set (during step 2):
To get (during step 3):
Note: If you inspect the
private_metadata
in the modal's JSON, you will see a base64-encoded string. The framework doeshttp_build_query
andbase64_encode
t…