Skip to content

Commit de4d273

Browse files
committed
Adding more docs.
1 parent 9de6e76 commit de4d273

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

README.md

+22
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,28 @@ Formio.form($('form#myform'), function(err, submission) {
4444
});
4545
```
4646

47+
### Providing success and danger alerts.
48+
When using this library, you will need to provide the alerts and business logic once the submission is made. Using the form provided above,
49+
you could create a simple alert system using the following logic below the form declaration.
50+
51+
```
52+
<script type="text/javascript">
53+
var form = document.querySelector('form#myform');
54+
Formio.form(form, function(err) {
55+
var alert = document.createElement('div');
56+
if (err) {
57+
alert.setAttribute('class', 'formio-alert formio-danger');
58+
alert.appendChild(document.createTextNode(err));
59+
}
60+
else {
61+
alert.setAttribute('class', 'formio-alert formio-success');
62+
alert.appendChild(document.createTextNode('Submission Created'));
63+
}
64+
form.parentNode.insertBefore(alert, form);
65+
});
66+
</script>
67+
```
68+
4769
### Why is this different than a direct HTML form submit?
4870
You can submit a form to Form.io with HTML directly using our API endpoint as the action, but those submissions will be made
4971
anonymously. This code provides the authentication tokens which will allow you to do so using the authentication of the currently logged in user.

0 commit comments

Comments
 (0)