Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd39b477

Browse files
committed
Docs for Slack options field() method
Closes#13398
1 parente3d7c66 commitd39b477

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed
16.9 KB
Loading

‎notifier/chatters.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,44 @@ to add some interactive options called `Block elements`_::
9898

9999
$chatter->send($chatMessage);
100100

101+
Adding Fields and Values to a Slack Message
102+
-------------------------------------------
103+
104+
To add fields and values to your message you can use the
105+
:method:`SlackSectionBlock::field() <Symfony\\Component\\Notifier\\Bridge\\Slack\\Block\\SlackSectionBlock::field>` method::
106+
107+
use Symfony\Component\Notifier\Bridge\Slack\Block\SlackDividerBlock;
108+
use Symfony\Component\Notifier\Bridge\Slack\Block\SlackSectionBlock;
109+
use Symfony\Component\Notifier\Bridge\Slack\SlackOptions;
110+
use Symfony\Component\Notifier\Message\ChatMessage;
111+
112+
$chatMessage = new ChatMessage('Symfony Feature');
113+
114+
$options = (new SlackOptions())
115+
->block((new SlackSectionBlock())->text('My message'))
116+
->block(new SlackDividerBlock())
117+
->block(
118+
(new SlackSectionBlock())
119+
->field('*Max Rating*')
120+
->field('5.0')
121+
->field('*Min Rating*')
122+
->field('1.0')
123+
);
124+
125+
// Add the custom options to the chat message and send the message
126+
$chatMessage->options($options);
127+
128+
$chatter->send($chatMessage);
129+
130+
The result will be something like:
131+
132+
..image::/_images/notifier/slack/field-method.png
133+
:align:center
134+
135+
..versionadded::5.1
136+
137+
The `field()` method was introduced in Symfony 5.1.
138+
101139
Adding Interactions to a Discord Message
102140
----------------------------------------
103141

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp