When you create an input form using User Input elements, you can add customized success and error messages that are displayed only when a user tries to submit data to a collection. For any element that allows you to add a link (e.g. a button), you can automatically add success and error messages to your form in the Connect panel of the element.
What if you want to use code to trigger form submission based on some other user action besides clicking an element that has a link? For example, you may want a radio button selection to trigger the submit.
As long as you connect the input elements to the same dataset as the triggering element and use any of the dataset APIs that trigger a save, the submit messages will be displayed.
Note: You can only add form submit messages if your connected dataset is set to either Write-only or Read & Write.
- Add input elements to create your form and connect them to the same dataset.
- Add a Text element to your page where you want the submit message to appear, modify the text for your message, and click Connect to Data.
- Connect the Text element to the same dataset as the input elements for your form.
- In the Connection Options section under Form Messages, select either Submit Succeeded or Submit Failed.
- Add an event handler for the event that you want to the trigger the submit.
- Inside the event handler function call one of the APIs that saves the current dataset item.
- Repeat steps 2 through 4 to create both messages, if needed.
Tip: Because success and failure messages never appear together, you can position one text element to completely overlap another on your page so the messages take up less space. Only the relevant message is displayed when a user attempts to submit data.