Form Partials#
TemplateX creates starter forms in:
- contact.php
You can also create these files by hand.
{{ form:contact }} <form> <label>Name</label> <input name="name" required> {{ form:error:name }} <button type="submit">Send</button> </form>{{ /form:contact }}Use the partial anywhere:
<Forms.Contact />Form Names#
The name after form: becomes the form key:
{{ form:newsletter }} ...{{ /form:newsletter }}Names are normalized to safe keys. first-name and first_name are treated as first_name internally.
Form Attributes#
Attributes on the TemplateX form tag are passed to the generated <form> element:
{{ form:contact class="contact-form" redirect="/thank-you/" }} ...{{ /form:contact }}redirect sends successful non-AJAX submissions to another URL.
If you write your own literal <form> element inside the TemplateX form, TemplateX keeps its useful attributes and replaces it with the generated form element.