Name Triggers
Easily extend your Slapforms with name triggers to control email behavior, and much more.
What are name triggers?
Slapform recognizes certain name
attributes and uses them to control the behavior of emails, plugins, and more. All name triggers begin with slap_
such as slap_replyto
which controls the Reply-To address on notification emails.
Here's a list of all the Slapform special name trigger fields, along with the behaviors they control.
slap_request
Name | slap_request |
---|---|
Alternatives | none |
Type | HTML, AJAX |
Minimum Plan | none |
Default | Determined by Slapform |
Description | Normally, Slapform will intelligently attempt to determine your request type. This is important because AJAX requests are handled differently than HTML form submissions, and each request type has different features. However, you can override what Slapform determines by using this name trigger. If you do supply this, it must be either ajax or form. |
slap_replyto
Name | slap_replyto |
---|---|
Alternatives | |
Type | HTML, AJAX |
Minimum Plan | none |
Default | [email protected] |
Description | Change the reply-to address of the submission email you receive. The default reply-to address is ours, [email protected], but you can make it whatever you want with this Name Trigger. This Name Trigger will show up in the response email data. |
slap_debug
Name | slap_debug |
---|---|
Alternatives | none |
Type | HTML, AJAX |
Minimum Plan | none |
Default | false |
Description | Enables debugging features. The submission page will show the response from our server (see an example). |
slap_honey
Name | slap_honey |
---|---|
Alternatives | none |
Type | HTML, AJAX |
Minimum Plan | none |
Default | |
Description | A honeypot for spam. This name trigger works best as a hidden <input> field. Now, if a bot tries to fill out your form, the submission will be discarded. |
slap_subject
Name | slap_subject |
---|---|
Alternatives | none |
Type | HTML, AJAX |
Minimum Plan | none |
Default | New Slapform Submission |
Description | Change the subject of the submission email you receive. |
How to use name triggers
Slapform name triggers can be used in 3 different ways and they will all mostly function in a similar fashion:
- As a
name
attribute on an HTML<input>
- Inside the
data
object of a JavaScript request. - In the query string of the action attribute on an HTML form.
HTML name trigger example
Below is a "kitchen-sink" example utilizing all of the available name triggers. Copy and paste and customize to your needs!
<form method="POST"
action="https://api.slapform.com/[email protected]">
<input type="text" name="name">
<input type="email" name="slap_replyto">
<input type="text" name="slap_subject">
<textarea type="text" name="message"></textarea>
<input type="text" name="slap_debug" value="false" hidden>
<input type="text" name="slap_honey" hidden>
<input type="text" name="slap_redirect" value="https://yourwebsite.com" hidden>
<button type="submit">Submit</button>
</form>
Pro tip
It's generally a great idea to use the form inputs for user input and the query string for things set by you (the developer). The example below exemplifies this.
<form method="POST"
action="https://api.slapform.com/[email protected]&slap_debug=false&slap_redirect=https://yourwebsite.com&">
<input type="text" name="name">
<input type="email" name="slap_replyto">
<input type="text" name="slap_subject">
<textarea type="text" name="message"></textarea>
<input type="text" name="slap_honey" hidden>
<button type="submit">Submit</button>
</form>
Javascript name trigger example
Below is a "kitchen-sink" example utilizing all of the available name triggers. Copy and paste and customize to your needs!
<script src="https://cdn.jsdelivr.net/npm/slapform@latest/dist/index.min.js"></script>
<script type="text/javascript">
var slapform = new Slapform(); // The script above exposes the global variable 'Slapform'
slapform.submit({
form: '{form_id}', // Replace this with the form id you created in step 1
data: { // The data you want submitted and emailed to you
name: 'Jon Snow',
message: 'Hello World! This is my first Slapform submission.',
slap_subject: 'My Favorite Message',
slap_replyto: '[email protected]'
slap_debug: false,
slap_honey: '',
/* These Slapform Name Triggers exist but aren't applicable to AJAX submissions */
// slap_redirect: 'https://yourwebsite.com',
// slap_captcha: false,
}
})
.then(function (response) { // This function runs only on success
console.log('Success!', response);
})
.catch(function (response) { // This function runs only on error
console.log('Fail!', response);
})
</script>