-
Notifications
You must be signed in to change notification settings - Fork 0
/
sampleForm.twig
46 lines (40 loc) · 2.1 KB
/
sampleForm.twig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{% extends "_layout" %}
{% set form = craft.formBuilder2.getFormByHandle('contactForm') %}
{% set formSettings = form.formSettings %}
{% set spamProtectionSettings = form.spamProtectionSettings %}
{% set tabs = form.fieldLayout.getFieldLayout().getTabs() %}
{% set scripts = craft.formBuilder2.includeScripts(form) %}
{% block content %}
<form method="post" accept-charset="utf-8" name="{{ form.handle }}" class="formbuilder2" id="{{ form.handle }}"{% if formSettings.hasFileUploads == '1' %} enctype="multipart/form-data"{% endif %}>
<input type="hidden" name="action" value="formBuilder2/entry/submitEntry">
<input type="hidden" name="formRedirect" data-custom-redirect="{{ formSettings.formRedirect.customRedirect }}" value="{{ formSettings.formRedirect.customRedirectUrl }}">
<input type="hidden" name="formHandle" value="{{ form.handle }}">
{% if spamProtectionSettings.spamTimeMethod == '1' %}<input type="hidden" name="spamTimeMethod" value="{{ 'now'|date('U') }}">{% endif %}
{% if spamProtectionSettings.spamHoneypotMethod == '1' %}<div style="display:none;"><label for="email-addresss-new">{{ spamProtectionSettings.spamHoneypotMethodMessage }}</label><input name="email-address-new" value="" id="email-addresss-new"></div>{% endif %}
{# Fields #}
{% for tab in tabs %}
{% set fields = tab.getFields() %}
<fieldset class="{{ tab.name |lower|replace(' ', '-') }}">
<legend>{{ tab.name }}</legend>
{% for field in fields %}
{% set input = craft.formBuilder2.getInputHtml(field) %}
{{ input |raw }}
{% endfor %}
</fieldset>
{% endfor %}
{# Errors/Success Messages #}
<div class="notifications">
<p class="notification error-message">{{ craft.session.getFlash('error') | raw }}<p>
<p class="notification success-message">{{ craft.session.getFlash('success') | raw }}</p>
{% set errors = (errors is defined ? errors : null) %}
{% if errors %}
<ul class="errors">
{% for error in errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
{% endif %}
</div>
<button type="submit">Submit Message</button>
</form>
{% endblock %}