Modal Form
"Modal Form" action type is used to show modal form and get some input from user with great UI.
How it is useful?#
You can create an action that will show a modal form with some inputs that user can fill and submit, executing another action to process the data.
The behavior and settings#
Please refer to Modal Forms article to get familiar with general settings and features.
Information
-
Modal Forms can be only executed by Slash Commands directly or by Message Components.
-
Modal Form can't execute another form on submit.
Example#
For example, you want to create a simple user profile command. To do it:
-
Create a new custom command (note the already existing action, it's the default one, don't touch it just yet);
-
Create a new action named "Submit" and select "Send Message" as action type, check "Ephemeral Message" and enter the following in the template:
{% do member.getAttribute('profile').update(modal.values.profile) %} New profile has been successfully saved. {{ modal.values.profile }}
-
Create a new action named "Dialog" and do following:
- Select the "Modal Form" as action type;
- Set its title to "Update Profile";
- Set its submit action to "Submit" you have previously created:
-
Add a new multiline Text Input component, fill label with "Enter profile", enter
profile
as identifier, check "Required" and enter the following template as its Default Value:{{ member.getAttribute('profile').value }}
-
In the default action from first step, make sure it's a "Send Message" action, enter the following as a template to show the current profile information:
{{- (member.getAttribute('profile').value) ?: 'No information' -}}
Add a new Button component with label "Update", any identifier and set its action to "Dialog" action.
-
Save.