The gv-form
tag allows you to power your html forms with governor. With the gv-form
tag you can quickly and easily configure and send contact form responses via email.
For more information on configuring forms in app please see our Forms User Documentation.
Important note: In order for an input value to be captured it must have a name attribute attached. All inputs without name attributes will be ignored. Only letters should be used in name attributes. No spaces or special characters are allowed.
Tag
<form gv-form="myform" method="POST">
<input type="text" name="name">
<input type="submit" value="Submit">
</form>
Example:
<form gv-form="myform" action="https://forms.governor.io/forms/send/5a568b40d4d47c50dc2cd53x" method="POST">
<input type="text" name="name">
</form>
Note:
Contact forms must be configured via the form control.
AJAX Submission
In addition to a standard server-side form POST with redirect url. The gv-form tag also supports ajax/client side requests. Ajax requests can be used to accomplish things like submitting forms without page refreshes.
Note:
An "ajax=true" querystring parameter must be present on form requests that are submitted via Ajax / client side scripts. The submission will still work without this query parameter. But a redirect will be returned instead of a success message.
Example using jQuery's ajax function:
// setup the contact form, method, url, and paremeters
var $form = $('#contact-form');
var url = $form.attr('action');
var method = 'POST';
var ajaxParameter = '?ajax=true';
var request;
// setup the contact form submission
$form.submit(function (e) {
// stop the default form submission so we can use ajax
e.preventDefault();
// make the form submission request
request = $.ajax({
data: $form.serialize(),
method: method,
url: url + ajaxParameter
});
// handle the success
request.done(function (resp) {
console.log(resp);
});
});