Skip to main content

Use Name Triggers

Easily extend your Slapforms with name triggers to control email behavior, and much more.


Understand 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

Nameslap_request
Alternativesnone
TypeHTML, AJAX
Minimum Plannone
DefaultDetermined by Slapform
DescriptionNormally, 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

Nameslap_replyto
Alternativesemail
TypeHTML, AJAX
Minimum Plannone
Default[email protected]
DescriptionChange 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

Nameslap_debug
Alternativesnone
TypeHTML, AJAX
Minimum Plannone
Defaultfalse
DescriptionEnables debugging features. The submission page will show the response from our server.

slap_honey

Nameslap_honey
Alternativesnone
TypeHTML, AJAX
Minimum Plannone
Defaultnull
DescriptionA 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

Nameslap_subject
Alternativesnone
TypeHTML, AJAX
Minimum Plannone
DefaultNew Slapform Submission
DescriptionChange the subject of the submission email you receive.

Implement 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.

Try the 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>

Try the 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();
  slapform.submit({
    form: '{form_id}',
    data: {
      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: ''
    }
  })
  .then(function (response) {
    console.log('Success!', response);
  })
  .catch(function (response) {
    console.log('Fail!', response);
  })
</script>