Forms

Creating and submitting forms

There is a form handler. If you construct a form, with the action of “/site_api/submit_form” then your form will be processed by the internal form submission engine.

This saves the contents of the form, and it can email the contents of the form to one or more of your site’s users.

You can also view saved forms in the dashboard at https://website.glass

Form Validation

All form validation should happen on the frontend, or alternately in a webhook. The form handler just saves the data that comes in.

Redirect and Success Message

You can set a redirect with <input name=redirect /> field. This is where the form submitter will be redirected after the form is completed.

Emailing Responses to yourself

Email sending is limited to designers/admins/editors of your site (that’s you!). To email a form create a input or select field on your form with the attribute name=to and the value of the *user id or email” to email to.

You can also email to multiple users, by separating values by commas.:

<input name="to" type="hidden" value="123213a-12213sfkjlav-1212" />
<input name="to" value="issac@servee.com, 8846723-564646546546-2134" />

You can also use a select or multi-select

<p>Who is your favorite?</p>
<select name="to">
  <option value="123213a-12213sfkjlav-1212">Issac</option>
  <option value="8846723-564646546546-2134">Kasey</option>
</select>

Setting the Reply-To value of the email

To reply to the person who sent you an email, set the name=email on a form.

Example form

Here’s a full example form:

<form action="/siteapi/submit_form" class="form-horizontal" id="contact" method="post" name="contact">

  <!-- this field emails you! -->
  <input name="to" type="hidden" value="issac@servee.com">

  <!-- this field sets the redirect -->
  <input name="redirect" type="hidden" value="/success">

  <div class="form-group" id="div_id_your_name">
    <label class="control-label required-field" for="id_your_name">Your name</label>
    <div class="">
      <input class="charfield required form-control" id="id_your_name" maxlength="2000" name="your_name" required="" type="text">
    </div>
  </div>

  <!-- this field sets the reply-to header -->
  <div class="form-group" id="div_id_e_mail_address">
    <label class="control-label required-field" for="email">E-mail address</label>
    <div class="">
      <input class="emailfield required form-control" id="email" maxlength="2000" name="email" required="" type="email">
    </div>
  </div>

  <div class="form-group" id="div_id_phone_number">
    <label class="control-label" for="id_phone_number">Phone Number</label>
    <div class="">
      <input class="charfield form-control" id="id_phone_number" maxlength="2000" name="phone_number" type="text">
    </div>
  </div>

  <div class="form-group" id="div_id_message">
    <label class="control-label" for="id_message">Message</label>
    <div class="">
      <textarea class="charfield form-control" cols="40" id="id_message" maxlength="2000" name="message" rows="10"></textarea>
    </div>
  </div>

  <div class="form-actions">
    <input class="button" type="submit" value="Submit">
  </div>
</form>