Skip to content

Instantly share code, notes, and snippets.

@jacobovidal
Last active March 2, 2020 10:30
Show Gist options
  • Save jacobovidal/cac1875aec38ecd0eb34107400e25586 to your computer and use it in GitHub Desktop.
Save jacobovidal/cac1875aec38ecd0eb34107400e25586 to your computer and use it in GitHub Desktop.
AMP form example with Arengu
<!doctype html>
<html ⚡>
<head>
<meta charset="utf-8">
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-form" src="https://cdn.ampproject.org/v0/amp-form-0.1.js"></script>
<script async custom-template="amp-mustache" src="https://cdn.ampproject.org/v0/amp-mustache-0.2.js"></script>
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
</head>
<body>
<form method="POST" action-xhr="https://api.arengu.com/forms/:id/submissions/">
<input name="name" type="text" placeholder="Full Name" required="true">
<input name="email" type="email" placeholder="Email" required="true">
<button type="submit">Submit</button>
<div submit-success>
<p>success</p>
</div>
<div submit-error>
<p>fail</p>
</div>
</form>
</body>
</html>
@bhaskartalla
Copy link

Above code doesn't seems to be working on AMP playground..

@jacobovidal
Copy link
Author

jacobovidal commented Mar 2, 2020

Above code doesn't seems to be working on AMP playground..

This code doesn't work because it requires you create a form in Arengu and replace the :id from <form method="POST" action-xhr="https://api.arengu.com/forms/:id/submissions/"> by your form ID. And also replace the input name attributes by the same field IDs you create in Arengu.

You can find more information at: https://blog.arengu.com/how-to-create-implement-forms-amp-pages/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment