form( options )

Ampify's conversion algorithm automatically converts all forms to amp-form, so usually you wouldn't be required to use this function.

If you're having a problem with the created form, make sure that your response is complient with the amp-form specificaions. e.g. all the CORS headers are correct, and that the response is a valid AMP.

  • If you are unable to comply with amp-form's specifications, you can use Ampify's form proxy (see 'proxy' below), which takes care of these issues.

  • If your site is using WordPress, please use Ampify's WP plugin, which adds CORS headers by default. There's no need for a proxy service in this case.

  • options

    • Type: Object
    • A map of additional options to pass to the method.
      • url (optional)
        • Type: String
        • Change the form’s action to a new url. This is useful if the form’s url is set by a javascript code or if you have a dedicated end-point for AMP.
      • proxy (optional)
        • Type: Boolean
        • Default: False
        • Set proxy to True to use Ampify’s form proxy. The form proxy will add the necessary CORS headers and will return a valid json.
        • Please Note: When using Ampify's proxy, the form data is routed through Ampify's server. We don't access, save or use this data in any way whatsoever. The source code of the proxy is transparent and can be seen here.
      • success (optional)
        • Type: String
        • Default: Form submitted successfully
        • Change the default message that's being displayed on success.
        • You have an option to display a custom message from the response json using mustache templates. For example, to display the message from this response json: {“success”, true, “message”: “Thank you for subscribing!”}, set success to {{message}}.
      • error (optional)
        • Type: String
        • Default: Unable to submit Form
        • Similar to success, error changes the default message that's displayed when the response returns an error.
      • submit (optional)
        • Type: String
        • Default: Submitting…
        • Change the default message that's being displayed while the form is being submitted..


url: '',
proxy: true,
success: ‘This is my custom {{message}} from response json’